linux_sed 正则替换

目标 替换 test.data文件中的

原正则: (d{4}[^)]*?)

sed不支持 d 改为0-9

测试 :head test.data| sed -r "s/([0-9]{4}[^)]+)//g" 

grep测试: grep -P "(\d{4}[^)]*?)" test.data

替换:  sed -i  -r "s/([0-9]{4}[^)]+)//g" 

最新正则

(d{4}[^)]{0,5}[u4e00-u9fa5]{1,10}[^)]{0,15})

 php : 内部替换,注意 u  替换为 x { }   。最后追加  u是utf8

原文地址:https://www.cnblogs.com/cphmvp/p/4517534.html