gle*_*man 6 regex awk grep gnu sed
不同的工具以不同的方式实现 例如,匹配"foo"或"bar":
printf "%s\n" foo bar baz food | grep -o '\<\(fo\+\|bar\)\>'
printf "%s\n" foo bar baz food | awk '/\<(fo+|bar)\>/'
printf "%s\n" foo bar baz food | sed -n '/\<\(fo\+\|bar\)\>/p'
printf "%s\n" foo bar baz food | sed -nr '/\<(fo+|bar)\>/p'
Run Code Online (Sandbox Code Playgroud)
这些差异记录在哪里?
gle*_*man 14
得分了!我很高兴找到这个页面:https:
//www.gnu.org/software/gnulib/manual/html_node/Regular-expression-syntaxes.html
14.8正则表达式语法
Gnulib支持许多不同类型的正则表达式; 虽然底层特征相同或相同,但使用的语法各不相同.此处给出的不同类型的描述是自动生成的.
- awk正则表达式语法
- egrep正则表达式语法
- ed正则表达式语法
- emacs正则表达式语法
- gnu-awk正则表达式语法
- grep正则表达式语法
- posix-awk正则表达式语法
- posix-basic正则表达式语法
- posix-egrep正则表达式语法
- posix扩展的正则表达式语法
- posix-minimal-basic正则表达式语法
- sed正则表达式语法