I am attempting to create a regular expression with the constructor syntax like this new RegExp(\'\\bword\\b\', \'g\'), but it does not behave as expected. Rather i
new RegExp(\'\\bword\\b\', \'g\')
For a string \b means backspace.
\b
For a regex \b means word-boundary.
To make sure the regex version is used, add an extra backslash \ before each backslash in the string to escape the escape characters.
\