How to find a carriage return without feeding a line after it with a regular expression pattern?

I need to find a carriage return (\ r) that does not have a straight line (\ n) immediately after it, how would I do this using the regex pattern?

+6
source share
2 answers

What about the following regex with a negative representation:

\r(?!\n) 
+9
source

This should do the trick:

  Regex.Match("\rtext\r\ntext.", "\r[^\n]", RegexOptions.Multiline); 
+1
source

Source: https://habr.com/ru/post/894572/


All Articles