Closed AustinHeard closed 1 year ago
Hey @AustinHeard
This has to do with javascript's string processing. By the time \s
gets to regex, it's just s
because the \
before s
escapes the character s
itself. That's why when you add a second \
regex finally gets \\
Try it out:
'USBsCamera'.match(new RegExp('(?:USB\sCamera)'));
Thanks for the reply!
I was just wondering if the expression field should require both / s if JavaScript is selected, or maybe when you copy it is copies with 2?
The site's regex input field is just regex, not a javascript string - and this applies across the board. There's no string processing in the style of the regex engine selected.
But you can get a properly escaped version of it to plop into JS if you click code generator in the left sidebar.
Oh I didn't know that button was there. Thank you!
Bug Description
A whitespace character (\s) working in js where it should be \s
Reproduction steps
When I use this expression in a js file it does not match but when I add the second \ it works
Expected Outcome
no matches
Browser
Chrome 114
OS
Pop!_OS 22.04 LTS