Community
    • Login

    Bookmark lines regex

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 2.4k Views 2 Watching
    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.
    • Tanja CorellT Offline
      Tanja Corell
      last edited by

      Hi.

      I need to bookmark all lines with the following:

      /s/2593740/1/

      The number in bold changes from line to line.

      I’ve tried with:

      /s/[0-9]/1/ but that doesn’t seem to work.

      Meta ChuhM Jim DaileyJ 2 Replies Last reply Reply Quote 0
      • Meta ChuhM Offline
        Meta Chuh moderator @Tanja Corell
        last edited by

        @Tanja-Corell

        solution:

        source text:

        aaa/s/2593740/1/xxx
        bbb/s/3452352/1/xxx
        ccc/s/463345/1/xxx
        ddd/a/2236674/1/xxx
        eee/s/67894775679/1/xxx
        fff/s/8078/3/xxx
        

        mark search regex:

        /s/(.*?)/1/
        

        result:

        (bookmarked) aaa/s/2593740/1/xxx
        (bookmarked) bbb/s/3452352/1/xxx
        (bookmarked) ccc/s/463345/1/xxx
                     ddd/a/2236674/1/xxx
        (bookmarked) eee/s/67894775679/1/xxx
                     fff/s/8078/3/xxx
        
        1 Reply Last reply Reply Quote 0
        • Jim DaileyJ Offline
          Jim Dailey @Tanja Corell
          last edited by

          @Tanja-Corell
          [0-9] matches any one character in the set 0, 1, 2, …, 9.
          [0-9]+ matches one or more of the characters in the set 0, 1, 2, …, 9.

          That should explain why /s/[0-9]/1/ did not work for you.

          1 Reply Last reply Reply Quote 1
          • Tanja CorellT Offline
            Tanja Corell
            last edited by

            Thanks that did the trick.Does the regex work in any program that needs a regular expression or just in Notepad ++?

            1 Reply Last reply Reply Quote 0
            • Meta ChuhM Offline
              Meta Chuh moderator
              last edited by Meta Chuh

              it works on any similar regex engine eg php functions like preg_match_all()

              but you have to make sure to escape all characters that would be interpreted as a regex pattern part instead of a character you are searching for

              eg: if you use / as a regex start and end delimiter character, you have to write \/ for every slash you want to find to make regex search for the character /

              so /s/[0-9]+/1/ in a php example where you use / as regex start-end delimiters it has to be rewritten to:

              preg_match_all("/\/s\/[0-9]+\/1\//ms", $source_text, $matches_array);
              

              or you can use a different delimiter character:

              preg_match_all("#/s/[0-9]+/1/#ms", $source_text, $matches_array);
              

              then if you search for the physical character # you’ll have to write \#

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors