linux系统下正则表达式的基本运用
正则表达式
正则表达式是一种描述一组字符串的模式,为处理大量文本、字符串而定义的一套规则和方法,以行为单位进行处理。正则表达式分为两类:基本正则表达式(BRE)和扩展正则表达式(ERE)。在linux中使用正则表达式较多的有三个工具,分别为grep,sed和awk,这三个工具被称为linux文本处理的三剑客。1、正则表达式元字符集 2、基本组成部分
\d+ ‘325535’ ‘1243435’ ‘1’ \w? ‘’ ‘5’ ‘fff’ \w* ‘’ ‘hgvdhvehjrbj’ ‘vqwgr443v4v’ ‘$KaTeX parse error: Expected 'EOF', got '#' at position 1: #̲#q’[A-Z] [a-z]{…上冒号4.3、正则表达式使用例子1、“\d+” //正整数
3、“^((-\d+)|(0+))” //负整数
5、“^-?\d+KaTeX parse error: Expected group after '^' at position 13: ” //整数
6、“^̲\d+(\.\d+)?” //非负浮点数(正浮点数 + 0)
7、“^(([0-9]+.[0-9][1-9][0-9])|([0-9][1-9][0-9].[0-9]+)|([0-9][1-9][0-9]))KaTeX parse error: Expected 'EOF', got '\d' at position 19: …/正浮点数
8、“^((-\̲d̲+(\.\d+)?)|(0+(…” //非正浮点数(负浮点数 + 0)
9“^(-(([0-9]+.[0-9][1-9][0-9])|([0-9][1-9][0-9].[0-9]+)|([0-9][1-9][0-9])))KaTeX parse error: Expected 'EOF', got '\d' at position 20: …负浮点数
10、“^(-?\̲d̲+)(\.\d+)?” //浮点数
11、“1+” //由26个英文字母的大写组成的字符串
13、“2+” //由数字和26个英文字母组成的字符串
15、“^\w+KaTeX parse error: Expected 'EOF', got '\d' at position 41: …串
16、^[A-Za-z\̲d̲]+([-_.][A-Za-z… 邮箱
17、“3+://(\w+(-\w+))(.(\w+(-\w+)))(?\S)?KaTeX parse error: Expected 'EOF', got '\d' at position 17: … //url
18、/^(\̲d̲{2}|\d{4})-((0(…/ // 年-月-日
19、/^((0([1-9]{1}))|(1[1|2]))/((0-2)|(3[0|1]))/(d{2}|d{4})” //Email
21、/^((+?[0-9]{2,4}-[0-9]{3,4}-)|([0-9]{3,4}-))?([0-9]{7,8})(-[0-9]+)?$/ //电话号码