Bookmark lines regex
-
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.
-
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/xxxmark 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 -
@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.
-
Thanks that did the trick.Does the regex work in any program that needs a regular expression or just in Notepad ++?
-
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
\#
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