Re: [问题] sed , grep 匹配问题

楼主: ericshei (ericshei)   2020-02-26 09:53:04
非常感谢您的说明
GNU的实作不是标准的POSIX standard
https://www.regular-expressions.info/posix.html
上文提到如下:
Some implementations support \? and \+ as an alternative syntax to \{0,1\} and \{1,\}, but \? and \+ are not part of the POSIX standard.
所以这里的\+己经不是escape +为字符的概念(modifier + to character + ),而是本质上\+是一个modifier
所以 \+ 同 + 同 {1,}
测试一下,把+换成#结果就是原本理解的概念了.
$ echo '11162,1,2020-02-17 19:59:31:696,#000000000 00:01:39.097' | sed 's/^..*,[1-9]*,\#/REPLACED/g'
11162,1,2020-02-17 19:59:31:696,#000000000 00:01:39.097

Links booklink

Contact Us: admin [ a t ] ucptt.com