桑达精确匹配 [英] Sed match exact
问题描述
我目前使用的/串/ new_string / g的
来通过一些的CSV文件,但是我运行到在以下情况下难度:
I'm currently using 's/string/new_string/g'
to go through some CSV files, however I'm running into difficulty in the following scenario:
我要替换192.168.0.11
的实例,但它也赶上192.168.0.111的实例
。
I want to replace instances of '192.168.0.11'
, however it's also catching instances of '192.168.0.111'
.
我怎样才能确保SED只待价而沽192.168.0.11
,而不是192.168.0.111
?我显然有重复这对于很多变数,所以一些易于扩展将AP preciated。
How can I ensure sed only grabs '192.168.0.11'
and not '192.168.0.111'
? I'll obviously have to repeat this for many variables, so something easily scalable would be appreciated.
谢谢!
推荐答案
我不知道你正在使用正则表达式是,但如果你想192.168.0.11的精确匹配,你可以使用: S / \\< 192 \\ .168 \\ .0 \\ 0.11 \\> //摹
I'm not sure what the regex you are using is, but if you want an exact match of '192.168.0.11' you can use:
s/\<192\.168\.0\.11\>//g
的 \\&LT; \\方式&gt;
强制精确匹配
这篇关于桑达精确匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!