regex working on net page is not working in npp
at a website, a user asked he wanted to get the content between second-to-last and last forward slash, or so I understood.
i.e, from “https://www.facebook.com/pages/Something/976313416535/”, he wanted 976313416535 (which may or may not be numbers in other cases, I guess)
I tested on https://regex101.com/, this regex will find the last set of numbers.
meaning, replacing it with
will give the last desired string.
What did I miss? How is npp regex different from all above regex?
That find/replace regex pair works fine for me on Notepad++, although one would do well to note that you do not need either of the
\that you show there. As to why it isn’t working for you…maybe show a screenshot of your Replace window?
note that you do not need either of the
I meant the two
\in the Find expression, not the single one in the Replace expression – that one is totally necessary.
Meta Chuh last edited by Meta Chuh
not the single one in the Replace expression – that one is totally necessary.
oh. so, forward slash / is not a control character in regex and it need not be escaped.
good enough. I got it now for ever.
however, escaping a non-control character also should not change the behavior of regex. It sort of double emphasizes that the next letter is to be taken literally, not in its control meaning, just in case it has any control meaning I am not aware of.
the above expression as well as the revised expression
both are selecting entire single line from start to end and saying "found 1st occurrence, reached end of file, there is a single line as above in the test text file, that is with or without crlf at the end of line, in case that is required to mark $ end-of-line.
@ Alan Kilborn
No, when I removed those two \ from find, the regex is not giving error in npp, but then the regex is not working on regex101 site.
Now I am sure that the site’s regex and npp’s regex are different.
however, escaping a non-control character also should not change the behavior of regex
guy038 last edited by
To select any area, even empty, between the
penultimateslash and the
lastslash of an Internet address, you could use the search regex, below :
Just test it against the sample text below :
https://www.mysite.com/Something/976313416535/Text https://www.mysite.com/Something//Text https://www.mysite.com/Something/976313416535/ https://www.mysite.com/Something// https://www.mysite.com/Something/976313416535 https://www.mysite.com/Something/97//631/34/abcde/ https://www.mysite.com/Something/97//631/34/abcde// https://www.mysite.com/Something/97//631/34/abcde/12345
When doing a replacement ( or a suppression ), with the search regex, above, remember that you must use the
Replace Allbutton, exclusively ;-)) The step-by-step replacement, with the
Replacebutton does not work, due to the
yes, it could find the correct part.
Thanks a gig, dear sir. :-)