It looks like MATCHES incorrectly processing “#” symbol.
MATCHES “.*[^#].*” => TRUE
does nothing.
Yes it works. Do you know my original is not working for # as it works for other symbols?
Hi @izaychik63,
The node and regex works fine. Here is why:
First, if you want to match a string containing no # character, you can use this regex:
[^#]+
or [^#]*
as @umutcankurt has suggested.
When you use
.*[^#].*
This is how it is interpreted:
any number of any character - a single character which can be anything other than # - any number of any character, So [^#] means ANY character other than #.
“1#2” is a match for .*[^#].*
since first .*
matches everything until the last character where [^#]
matches 2 , the second .*
matches nothing (0 number of any character) and the pattern is a true match.
But the opposite:
.*[#].*
This matches any string containing #. The first .*
matches anything until the last # character, [#]
matches the last # character and the second .*
matches everything afterwards. So if there is no match for [#]
the pattern is not a true match.
Hope I could explain it well.
PS
This behavior is the same for all characters.
Thank you, Armin. I consider you one of the most comprehensive supporter on the forum.
I learn thanks to you.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.