I have a string:
\r\ndsadasdsad\das\rdasdsacxz\ndasdsa\r\nadsadas\e
I want to make a regexp that will match all characters with '\' in front of them, but not "\r\n", so it would be '\.' without '\r\n'
I have a string:
\r\ndsadasdsad\das\rdasdsacxz\ndasdsa\r\nadsadas\e
I want to make a regexp that will match all characters with '\' in front of them, but not "\r\n", so it would be '\.' without '\r\n'
This regex should match a single character that is preceded by a \
, but is not part of the sequence \r\n
:
(?:(?<!\\)|(?!r\\n))(?:(?<!\\r\\)|(?!n))(?<=\\).
You can find an explanation here.
This will match all characters which are not "n" or "r" and which have a slash in front of them.
(?<=\\)[^rn]
Ok, this should do what you're asking.. :
As per your question this matches "ALL characters with '\' in front of them, but not '\r\n'"
Test String:
\r\ndsadasdsad\das\rdasdsacxz\ndasdsa\r\nadsadas\e
Regex:
(?:\\r\\n\w*)|(\w+)
Matches:
MATCH 1 'das'
MATCH 2 'rdasdsacxz'
MATCH 3 'ndasdsa'
MATCH 4 'e'
Here's an example: http://regex101.com/r/lE7gI7