linux系统下正则表达式的基本运用

正则表达式
正则表达式是一种描述一组字符串的模式,为处理大量文本、字符串而定义的一套规则和方法,以行为单位进行处理。正则表达式分为两类:基本正则表达式(BRE)和扩展正则表达式(ERE)。在linux中使用正则表达式较多的有三个工具,分别为grep,sed和awk,这三个工具被称为linux文本处理的三剑客。1、正则表达式元字符集 linux系统下正则表达式的基本运用2、基本组成部分linux系统下正则表达式的基本运用 \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+//+02[09][19][09]” //非负整数(正整数 + 0) 2、“^[0-9]*[1-9][0-9]*” //正整数
3、“^((-\d+)|(0+))//+04[09][19][09]” //非正整数(负整数 + 0) 4、“^-[0-9]*[1-9][0-9]*” //负整数
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+//2612[AZ]+” //由26个英文字母组成的字符串 12、“^[A-Z]+” //由26个英文字母的大写组成的字符串
13、“2+//2614[AZaz09]+” //由26个英文字母的小写组成的字符串 14、“^[A-Za-z0-9]+” //由数字和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})/////20([w.]+)@(([[09]1,3.[09]1,3.[09]1,3.)(([w]+.)+))([azAZ]2,4[09]1,3)(]?)/ // 月/日/年 20、“^([w-.]+)@(([[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.)|(([w-]+.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(]?)” //Email
21、/^((+?[0-9]{2,4}-[0-9]{3,4}-)|([0-9]{3,4}-))?([0-9]{7,8})(-[0-9]+)?$/ //电话号码


  1. A-Za-z ↩︎

  2. a-z ↩︎

  3. a-zA-z ↩︎