I’m looking for a regex to ensure that my string only contains \r\n for newline and not \r or \n.
Sample text without errors:
Hello,\r\n\r\nWelcome on board of our brand-new cruise line.\r\nKind regards
Sample text with errors:
Hello\r\r\nWelcom on board of our brand-new cruise line.\nKind regards
Thank you in advance!
Kind regards, Danny
Try this regex:
if it matches, your text contains a loose
\ror\nNote: if you put this in string you need to escape the \r\n twice. or even better put it in
@string like this@"(\r[^\n])|([^\r]\n)"Edit: example:
Output:
Link: http://ideone.com/mauNN