I get unexpected results with this code:
'foo'.match(new RegExp('\bfoo\b'));
Why does this return null while this returns "foo"?
'foo'.match(new RegExp('foo'));
Does the word boundary marker match the start and end?
EDIT: I need the regex to be a string because I am inserting variables into it.
javascript regex word-boundary
mattalxndr
source share