source is 1234567890
, the regular expression ((?<=\d)\d{3})*\b
can match: 234567890
, so i think sed
should replace 234567890
with TEST
, but the result is: 1234567890
, why?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
look-behind is not supported by sed. you could try ssed (super sed), it supports perl mode, (-R) then you could pass perl style regex to it. e.g. look ahead/behind.
see the feature list:
https://launchpad.net/ssed
回答2:
You need to rewrite the regex without lookbehind:
s/(\d)(?:\d{3})*\b/\1TEST