Using this bit of code trims out hidden characters like carriage returns and linefeeds with nothing using javascript just fine:
value = value.replace(/[\\r\\
To just remove them, this seems to work for me:
value = value.replace(/[\r\n]/g, "");
You don't need the *
after the character set because the g
flag solves that for you.
Note, this will remove all \r
or \n
chars whether they are in this exact sequence or not.
Working demo of this option: http://jsfiddle.net/jfriend00/57GtJ/
If you want to remove these characters only when in this exact sequence (e.g. only when a \r
is directly followed by a \n
, you could use this:
value = value.replace(/\r\n/g, "");
Working demo of this option: http://jsfiddle.net/jfriend00/Ta3sn/