Community
    • Login

    how to delete text in notepad ++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 2 Posters 999 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.
    • Mert dirkM
      Mert dirk
      last edited by

      i have links like these:
      localhost/wordpress/2012/03/09/drake-fire-hole/d54ce0c6154c4d64942db35ff98b327f.jpeg
      localhost/wordpress/2014/07/04/dragon-ball-z/a34ce0c6377453fd36492d435983279.jpeg
      localhost/wordpress/2018/08/02/sun-flower/fgrw43w54c4d6494324db3ff08b3327.jpeg

      i want it to be: localhost/wordpress/2018/08/fgrw43w54c4d6494324db3ff08b3327.jpeg

      how can i get this i tryd but cant figure it out i tryd some regex but cant get working

      Hope someone can help me with this! many thanks

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Mert dirk
        last edited by

        @Mert-dirk said in how to delete text in notepad ++:

        how can i get this i tryd but cant figure it out i tryd some regex but cant get working

        Why not share what you tried, so we can explain what went wrong, and show you how to figure out how to fix it, rather than just handing you an answer that you likely won’t understand?

        But maybe I’m wrong, and the following will make perfect sense to you, and will cause you to immediately understand why your previous attempts didn’t work. (Doubtful, but maybe.)

        FIND = (localhost/wordpress/\d{4}/\d{2}/).*?/(\w+\.jpeg)
        REPLACE = $1$2
        MODE = Regular Expression
        REPLACE ALL

        ----

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        Mert dirkM 2 Replies Last reply Reply Quote 2
        • Mert dirkM
          Mert dirk @PeterJones
          last edited by

          @PeterJones thank you for your fast respond!. this is working! i dont understand regex so much i found some on the forum and google but all was not working, how can i learn this u have some tutorial somewhere i can use?

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Mert dirk
            last edited by

            @Mert-dirk said in how to delete text in notepad ++:

            how can i learn this u have some tutorial somewhere i can use?

            Did you see my set of five links in the “Useful References”? Did you notice that one of them was a FAQ that explains where to find other regular expression documentation?

            Mert dirkM 1 Reply Last reply Reply Quote 3
            • Mert dirkM
              Mert dirk @PeterJones
              last edited by

              @PeterJones i gonna check it out. sometimes i need this kind of stuff. many thanks to you for helping!

              1 Reply Last reply Reply Quote 0
              • Mert dirkM
                Mert dirk @PeterJones
                last edited by

                @PeterJones and if i want for example

                localhost/wordpress/fgrw43w54c4d6494324db3ff08b3327.jpeg

                i do

                FIND = (localhost/wordpress/\d{2}/\d{4}/).*?/(\w+.jpeg)
                REPLACE = $1$2
                MODE = Regular Expression
                REPLACE ALL

                then its not working do i miss something?

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @Mert dirk
                  last edited by PeterJones

                  @Mert-dirk said in how to delete text in notepad ++:

                  then its not working do i miss something?

                  You didn’t understand the regex, and randomly changed it, so of course it won’t give you the right answer.

                  I will explain a few features of my regex that you apparently didn’t understand, and see if you can try to figure it out. I will link to each feature in the user manual so you can read more about it.

                  • (...) – things in parentheses go into “capture groups”, in order. Since I had two sets of parentheses, that goes into group1 and group2, which are referenced in the replacement as $1 and $2.
                  • \d – is a “single character match” for a “digit character”
                  • \d{N} – the {N} is a “multiplying operator”, which makes this sequence match "N digit characters
                  • .*? – “non-greedy” match “zero or more” of “any character”
                  • \w+ – “one or more” “single character match(es) for a word character”

                  So, what your edited regex is doing is saying "look for (localhost/wordpress/ followed by two digits then a slash then four digits then a slash) and put it all into group#1, then search for anything in between ending with a /, then (one or more word characters, followed by .jpeg ‡) and put the second parenthetical into group 2.

                  With that, I hope you can figure out why your random edit didn’t work. And given that I told you what each section of the regex did, you should now know what to take out or move to get stuff out of the capture groups and into the in-between stuff, so that there is less in the replacement and thus, effectively, more is deleted.

                  ‡: technically, it is any character followed by the literal .jpeg … but it will work for your purposes, unless you have other text that has some non-dot character before jpeg)

                  And no, you got your freebie: I am not going to just hand you the answer a second time without you putting in a little effort. (And swapping a 2 and a 4 is not putting in effort; that was obviously a random guess on your part. Random guessing is not “effort”.)

                  Mert dirkM 1 Reply Last reply Reply Quote 1
                  • Mert dirkM
                    Mert dirk @PeterJones
                    last edited by

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