Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Bookmark lines regex

    Help wanted · · · – – – · · ·
    3
    5
    1679
    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 Corell
      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 Chuh Jim Dailey 2 Replies Last reply Reply Quote 0
      • Meta Chuh
        Meta Chuh @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 Dailey
          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 Corell
            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 Chuh
              Meta Chuh 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
              • First post
                Last post
              Copyright © 2014 NodeBB Forums | Contributors