正则表达式基础
正则表达式通过特殊的符号辅助,达到搜寻,删除,取代某些特定字符串的处理程序
1.
2.行首与行尾字符^ $
例如:
想在从行首匹配the
grep -n '^the' filename
想在从行尾开始匹配the
grep -n 'the$' filename
3.限定连续的RE 字符范围
例如:
想要找到2到5个o
grep -n 'o\{2, 5\}' filename
4.基础的正则表达
正则表达式基础
正则表达式通过特殊的符号辅助,达到搜寻,删除,取代某些特定字符串的处理程序
例如:
想在从行首匹配the
grep -n '^the' filename
想在从行尾开始匹配the
grep -n 'the$' filename
例如:
想要找到2到5个o
grep -n 'o\{2, 5\}' filename