I want to have my RegExp match anything but a newline
\r?\n
Regex recognizes common escape sequences such as \n for newline, \t for tab, \r for carriage-return, \nnn for a up to 3-digit octal number, \xhh for a two-digit hex code, \uhhhh for a 4-digit Unicode, \uhhhhhhhh for a 8-digit Unicode.
In regular expressions, we can match any character using period "." character. To match multiple characters or a given set of characters, we should use character classes.
"\n" matches a newline character.
An empty regular expression matches everything.
This should do it:
/(?:[^\r\n]|\r(?!\n))/g
This matches either any character except \r
and \n
or a single \r
that is not followed by \n
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With