Hello, I have a question on regular expressions and variables. My understanding is that the way to assign a variable string to a regular expression is to use the RegExp object like so:
let strVar = "string";
let regex = new RegExp(strVar);
But where I am having trouble is in understanding how I would construct a regular expression that uses a variable-string but that also uses the end-of-string β$β as in the following:
let regex = /string$/gm, where the "$" specifies position at end.
So, my question is: how do I use a variable string and the RegExp object to create a regex that also incorporates β$β ?
Thanks for any input!