I am using the following regex for detecting negative numbers:
([-]([0-9]*\.[0-9]+|[0-9]+))
But I want to skip the matches which are followed by $. If i use the folowing regex:
([-]([0-9]*\.[0-9]+|[0-9]+)[^\$])
It will match correctly the positions but will include the following character. For example in expression:
-0.6+3 - 3.0$
it will match:
-0.6+
I want to match only
-0.6
$ means "Match the end of the string" (the position after the last character in the string). Both are called anchors and ensure that the entire string is matched instead of just a substring.
So, yes, regular expressions really only apply to strings. If you want a more complicated FSM, then it's possible to write one, but not using your local regex engine. Save this answer.
\N Never Matches Line Breaks Perl 5.12 and PCRE 8.10 introduced \N which matches any single character that is not a line break, just like the dot does. Unlike the dot, \N is not affected by “single-line mode”.
([-]([0-9]*\.[0-9]+|[0-9]+)(?!\$)
You need a negative lookahead
here which will not consume and only make an assertion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With