Reputation: 88207
I want to have my RegExp match anything but a newline
\r?\n
Upvotes: 10
Views: 11651
Reputation: 655269
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
.
Upvotes: 9
Reputation: 10490
you can use the negative delimiter !
so (?!(\r|\n))
try that
or this maybe
.+?(?!(\r|\n))
Upvotes: 0
Reputation: 61727
As an alternative suggestion why not avoid regexp?
var newText = oldText.replace("\r","").replace("\n","");
This will return the string removing all the instances of \r
and \n
Upvotes: 0