linux 正则表达式 问题
在c写的程序中使用正则表达式。参考了https://www.cnblogs.com/stlong/p/6289107.html
在测试时,可同时识别出用圆括号定义的多组匹配串。
但是 "\\d" 表示的数字无法匹配。
google查找到https://stackoverflow.com/questions/6901171/is-d-not-supported-by-greps-basic-expressions
grep's default mode is (iirc) POSIX regex, and \d is pcre.
You can either pass -P to gnu grep, for perl-like regexps, or use [[:digit:]] instead of \d.
daenyth@Bragi ~ $ echo 1 | grep -P '\d'
1
daenyth@Bragi ~ $ echo 1 | grep '[[:digit:]]'
1
最终放弃了 regcomp()、regexec()、regfree()和regerror() - POSIX regex functions
采用pcre库 官网 https://www.pcre.org/
安装方式 https://www.cyberciti.biz/faq/debian-ubuntu-linux-install-libpcre3-dev/
posted on 2018-01-13 11:58 tantongchao 阅读(141) 评论(0) 收藏 举报
浙公网安备 33010602011771号