How to replace ‘$txt$’ in javascript.I want to replace all occurrences in the string
It’s what i tried
if (html.indexOf('$txt$') > -1) {
html = html.replace(/$txt$/ig, '<input type=text></input>');
}
but it won’t replace the string.What’s my mistake.Please help me
all you need to do is escape the $ sign since it has a meaning in a regular expression. Change it to
and it should be fine 🙂
edit: $ means end of line in a regular expression 🙂