I want a regex expression to replace the string which exactly matches it.
For e.g : - 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.
I want a regex expression to replace the string which exactly matches it.
For e.g : - 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.
Share Improve this question edited Jun 20, 2013 at 9:59 HamZa 14.9k11 gold badges55 silver badges75 bronze badges asked Jun 20, 2013 at 9:52 Sumodh NairSumodh Nair 1,6761 gold badge11 silver badges35 bronze badges 2 |2 Answers
Reset to default 11This should work for you:
/\@te\b/
Try this
var a = '@test @te @world @dimension';
var b = a.replace(/@te /, '');
@te\b
? ............ – zerkms Commented Jun 20, 2013 at 9:54