i am trying to write a regular expression for matching any words like which come in between “$”
for example
var myString = ” there was a $dog$# and a $rat$ in a town”;
i want to match dog and rat
i have written the expresion for it
var reg = /^$(.*)$/gmi
but that does not because , the “$” being special character of end of line , how can i escape it , can i use “\” ??
can you pelase suggest the correct expression .
As you said you should use ‘\’ to escape the special characters. Also ‘^’ is the start of the string you want to match for.
You should use the following: