I want a regex expression to replace the string which exactly matches it.
For eg : - var a = '@test @te @world @dimension
'
I need to replace ' @te
' .
Since ' @te
' exists in @test
as well so Replace statement is replacing the @test
in my case.
So could anyone please let me know how can this be done.
Just the exact matching string needs to be replaced.
这应该适合你:
/\@te\b/
Try this
var a = '@test @te @world @dimension';
var b = a.replace(/@te /, '');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.