Can you help me to understand / convert follwoing .net regex into java
@"(?<!\\)(?'M'[^|%])" ?
Can you help me to understand / convert follwoing .net regex into java
@"(?<!\\)(?'M'[^|%])" ?
This regex consists of two groups.
The first one (?<!\\)
is a lookbehind assertion. It will match only if the previous letter is not a backslash. The second one (?'M'[^|%])
is a named capturing group (called M), that matches any character except "|" and "%".
I.e. the regex will match "a", and not match "\a" or "%".
Java does not support the named capture, but
(?<!\\)([^|%])
should work fine for you. You'd reference the first group by number, instead of by name then.
Note that you may have to escape backslashes leading to (?<!\\\\)
for the first part.