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