正则表达式替换完全匹配的字符串 [英] Regex to replace exact matching string

查看:177
本文介绍了正则表达式替换完全匹配的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个正则表达式来替换与它完全匹配的字符串。

I want a regex expression to replace the string which exactly matches it.

例如: - var a ='@ test @te @world @dimension '

我需要替换' @te '。

由于' @te '存在于 @test 同样,在我的情况下,Replace语句正在替换 @test

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/

这篇关于正则表达式替换完全匹配的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆