I have a variable:
var str = "@devtest11 @devtest1";
I use this way to replace @devtest1
with another string:
str.replace(new RegExp('@devtest1', 'g'), "aaaa")
However, its result (aaaa1 aaaa
) is not what I expect. The expected result is: @devtest11 aaaa
. I just want to replace the whole word @devtest1
.
How can I do that?