157
rated 0 times
[
161]
[
4]
/ answers: 1 / hits: 16462
/ 9 Years ago, wed, may 20, 2015, 12:00:00
I am attempting to search a string for a specific word ('cow') using the following:
var regex = new RegExp('cow', '\b');
I only wish to target 'cow' and not words which contain 'cow' such as 'cowboy' or 'cows' using the 'b' expression, however this results in:
Uncaught SyntaxError: Invalid flags supplied to RegExp constructor
'b'
I have attempted to use 'b', 'b', '/b' but all result in the same error.
What is the correct expression I need to use?
More From » regex