作者ericshei (ericshei)
看板RegExp
标题Re: [问题] sed , grep 匹配问题
时间Wed Feb 26 09:53:04 2020
非常感谢您的说明
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
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 219.90.60.74 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/RegExp/M.1582681988.A.0BC.html