Regular Expression and sed command: echo 123456789

2019-08-29 07:15发布

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?

标签: regex linux sed
2条回答
女痞
2楼-- · 2019-08-29 07:38

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

查看更多
叼着烟拽天下
3楼-- · 2019-08-29 07:43

You need to rewrite the regex without lookbehind:

s/(\d)(?:\d{3})*\b/\1TEST
查看更多
登录 后发表回答