Quote:
Originally Posted by Old Pedant
Please do note that if you use the RegExp contructor you must escape the \ characters that are used in the regular expression escapes.
So:
Code:
s.replace(/a\sb/gi,""); // replace all "a b" or "A B" or even "a\tB" with nothing
var re = new RegExp( "a\\sb", "gi" );
s.replace( re, "" );
See the \\s in the constructor version?
|
That is a little misleading. Should be
Code:
s = s.replace(/a\sb/gi,""); // replace all "a b" or "A B" or even "a\tB" with nothing
var re = new RegExp( "a\\sb", "gi" );
s = s.replace( re, "" );