Community
    • Login

    reg-ex to clean txt file

    Scheduled Pinned Locked Moved General Discussion
    14 Posts 5 Posters 639 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • cisco779kC
      cisco779k
      last edited by cisco779k

      hi there, i have some txt like this:

      IMK_24346_0144545_474.aps
      9162 FG - https://www.shopper.com/file/kahste
      
      7-20200510.rag
      216d2 FA - https://www.shopper.com/file/4dLfhgfj6
      
      IMQ_20wa226_012349_113.ras
      20.44 SB - https://www.shopper.com/file/ba211
      
      IMR_2234r22_056305_111.raq
      1823 KH - https://www.shopper.com/file/dO3a6b
      
      IEG_2214406_123258_0140.rak
      21.11 OG - https://www.shopper.com/file/mosd32
      

      i need to clean lines and text, and have only address link, like this:

      https://www.shopper.com/file/kahste
      https://www.shopper.com/file/4dLfhgfj6
      https://www.shopper.com/file/ba211
      https://www.shopper.com/file/dO3a6b
      https://www.shopper.com/file/mosd32
      

      someone have a right reg-ex for this?
      thanks a lot for your help

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @cisco779k
        last edited by

        @cisco779k
        Why not convert all spaces to newlines. Then bookmark all lines with http. Then remove all non bookmarked lines.

        Terry

        1 Reply Last reply Reply Quote 3
        • Alan KilbornA
          Alan Kilborn
          last edited by

          @cisco779k

          After Terry’s suggestion, you may want to execute this replacement operation:

          Find: (?-is)^.+?(?=https:)
          Replace: nothing
          Search mode: Regular expression

          to remove what occurs before https on your lines.

          1 Reply Last reply Reply Quote 0
          • cisco779kC
            cisco779k
            last edited by cisco779k

            @ Terry
            thanks for your reply, but not easy for me follow your suggestion. you can provide and example?
            or you talk about Edit - Line operations - Remove empty Lines ?

            @ Alan
            thanks also for your reply. your regex can work. i need only to understand the first step …

            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @cisco779k
              last edited by

              @cisco779k

              Oops. Terry’s suggestion will work, without my add-on.

              1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn
                last edited by

                @cisco779k

                Terry’s solution involves:

                Find: \x20
                Replace: \r\n
                Search mode: Regular expression

                Then, Search menu > Mark with Find: https.

                Then Search menu > Bookmark > Remove Non-Bookmarked Lines.

                Mark OlsonM 1 Reply Last reply Reply Quote 2
                • Mark OlsonM
                  Mark Olson @Alan Kilborn
                  last edited by

                  @Alan-Kilborn
                  Just an addendum to this solution: it won’t work unless you check Bookmark line on the Mark menu, because that is not checked by default.

                  Alan KilbornA 1 Reply Last reply Reply Quote 2
                  • Alan KilbornA
                    Alan Kilborn @Mark Olson
                    last edited by

                    @Mark-Olson said in reg-ex to clean txt file:

                    Just an addendum to this solution: it won’t work unless you check Bookmark line on the Mark menu

                    Yep, for sure, meant to mention that…I just didn’t. :-)
                    Thanks for picking me up.

                    1 Reply Last reply Reply Quote 0
                    • cisco779kC
                      cisco779k
                      last edited by

                      oh yes Alan, your tip work like a charm
                      and thanks also to Mark Olson for your clarification

                      1 Reply Last reply Reply Quote 0
                      • cisco779kC
                        cisco779k
                        last edited by cisco779k

                        i’ve saved all steps to new macro, and this work fine.
                        also i’ve noticed that the macro is saved on shortcuts.xml file.
                        I wonder if you can save the macro to a separate file … (to not to forget it in the future)

                        Terry RT 1 Reply Last reply Reply Quote 0
                        • Terry RT
                          Terry R @cisco779k
                          last edited by Terry R

                          @cisco779k

                          Firstly, you have been a member of this forum since August 2017, so at least 5 years. You have asked a number of regex related questions and received answers in all cases.

                          You have been requested to start learning regex, see here, that was over 2 years ago, yet you still don’t appear to have learnt even the basics.

                          I supplied my solution last night via a smartphone, hence the shortness of the post. But I at least expected you to understand how to use that to solve your question.

                          I must say you appear to have been lucky in getting so many solutions. Normally we request users in your position to have at least tried to figure out an answer. Then present us with what you tried.

                          How about trying to learn now!

                          Terry

                          1 Reply Last reply Reply Quote 5
                          • cisco779kC
                            cisco779k
                            last edited by cisco779k

                            … useless polemic …

                            on my first post, i’ve ask help for a regex to my trouble. very hard for me.

                            maybe i would have at this solution on my own
                            (but thanks anyway to Alan for your support)

                            Alan KilbornA Lycan ThropeL 2 Replies Last reply Reply Quote -1
                            • Alan KilbornA
                              Alan Kilborn @cisco779k
                              last edited by

                              @cisco779k said in reg-ex to clean txt file:

                              but thanks anyway to Alan for your support

                              You’re welcome but I agree with Terry.
                              You need to start learning how to do such things.
                              For some reason I didn’t check your posting history before contributing thoughts to this thread.

                              1 Reply Last reply Reply Quote 2
                              • Lycan ThropeL
                                Lycan Thrope @cisco779k
                                last edited by Lycan Thrope

                                @cisco779k ,
                                You seem to have quite a vocabulary for a non-english speaker, so try using your intelligence for learning regex, rather than crying for help and using $20.00 word swipes at the volunteers, who I wouldn’t blame for letting your posts die from neglect from here on out. And yes, polemic fits this post just fine.

                                1 Reply Last reply Reply Quote 1
                                • First post
                                  Last post
                                The Community of users of the Notepad++ text editor.
                                Powered by NodeBB | Contributors