Closed Bug 474631 Opened 16 years ago Closed 16 years ago

javascript regexp: '\s+' not supported

Categories

(Firefox :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 23708

People

(Reporter: julien.t43+mozilla, Unassigned)

Details

User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; fr; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; fr; rv:1.9.0.5) Gecko/2008120121 Firefox/3.0.5 While trying to make a script with greasemonky, using regexp functions, i observe expression like 'foo\s+bar' don't work. 'foo bar' matches but not with '\s+'. for regexp, \s could be space, line return, tab, ... and it's a very useful identifier. Reproducible: Always Steps to Reproduce: 1. create a greasemonkey script 2. make the following code (from highlighter.user.js) x=new RegExp('(foo\s+bar)','gi'); rn=Math.floor(Math.random()*100); rid='z' + rn; b = document.body.innerHTML; b=b.replace(x,'<span name=' + rid + ' id=' + rid + ' style=\'color:#FFF;background-color:red;\'>$1</span>'); void(document.body.innerHTML=b); Actual Results: it will highlight nothing Expected Results: normal behavior matches: foo bar foo\tbar foo\nbar ...
'foo\sbar' is the same as 'foosbar'. You want 'foo\\sbar', see bug 23708 comment 8.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.