正则表达式
todd@todd-virtual-machine:/usr/share/dict$ egrep "^a.*t$" words匹配在words中以
^代表开始,a开头,.代表任意字符,*代表重复任意次数,t代表匹配的文件 words代表要匹配的文件夹。(如果没有*代表只匹配一次)
todd@todd-virtual-machine:/usr/share/dict$ egrep "^a.*t$" words |wc –w用管道命令显示出于匹配出多少个单词
254
todd@todd-virtual-machine:/usr/share/dict$ egrep "\<.at\>" words 匹配最后两字母为at单词
todd@todd-virtual-machine:/usr/share/dict$ egrep "\<.at\>" words | wc –w 显示数量有多少
28
todd@todd-virtual-machine:/usr/share/dict$ egrep "[abcdefg]at" words 匹配
todd@todd-virtual-machine:/usr/share/dict$ egrep "^[[:upper:]]t$" words匹配words中upper(大写字母)开头,t结尾的单词。[: :]中间的内容为字符类
At
It
Lt
Mt
Pt
St
upper(大写字母)、lower(小写字母)、digit(数字)、black(字表付或空格)space(空格)、graph(除字表符之外的所有)
原文链接:https://www.f2er.com/regex/361860.html