As I read the documentation a backslash is used to escape a character. So I coded the regular expression as:
xxx = new RegExp("\.$", "g");
This does not work and through trial and error I found that
new RegExp("\\.$", "g");
does work.
Is the documentation incorrect?
Use the
mflag to make$match end of lines, and escape the.:or:
In a string to get a literal backslash you need to escape it with another backslash.