It's a very elegant summary of regular expression from The AWK Programming Language.

1. The regular expression metacharacters are:

\ ^ $ . [ ] | ( ) * + ?

2. A basic regular expression is one of the following:

  • a nonmetacharacter, such as A, that matches itself.
  • an escape sequence that matches a special symbol: \t matches a tab.
  • a quoted metacharacter, such as \*, that matches the metaqcharacter literally.
  • ^, which matches the beginning of a string.
  • $, which matches the end of a string.
  • ., which matches any single character.
  • a character class: [ABC] matches any of the characters A, B, or C. Character classes may include abbreviations: [A-Za-z] matches any single letter.
  • a complemented character class: [^0-9] matches any character except a digit.

3. These operators combine regular expressions into larger ones:

  • alternation: A | B matches A or B.
  • concatenation: AB matches A immediately followed by B.
  • closure: A* matches zero or more A's.
  • positive closure: A+ matches one or more A's.
  • zero or one: A? matches the null string or A.
  • parentheses: (r) matches the same strings as r does.

Regular Expressions
Expression Matches
c  the nonmetacharacter c
\c  escape sequence or literal character c
 ^  beginning of string 
 $  end of string
 .  any character
 [$c_1$$c_2$...]  any character in $c_1$$c_2$
 [^$c_1$$c_2$...]  any character not in $c_1$$c_2$
[$c_1$-$c_2$]   any character in the range beginning with $c_1$ and ending with $c_2$
 [^$c_1$-$c_2$]  any character not in the range $c_1$ to $c_2$
 $r_1$|$r_2$  any string matched by $r_1$ or $r_2$
($r_1$)($r_2$)   any string xy where $r_1$ matches x and $r_2$ matches y; parentheses not needed around arguments with no alternations
 (r)*  zero or more consecutive strings matched by r 
 (r)+  one or more consecutive strings matched by r
 (r)?  zero or one string matched by r parentheses not needed around basic regular expressions 
 (r)  any string matched by r

Regular Expression的更多相关文章

  1. [LeetCode] Regular Expression Matching 正则表达式匹配

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  2. myeclipse中导入js报如下错误Syntax error on token "Invalid Regular Expression Options", no accurate correc

    今天在使用bootstrap的时候引入的js文件出现错误Syntax error on token "Invalid Regular Expression Options", no ...

  3. [LeetCode] 10. Regular Expression Matching

    Implement regular expression matching with support for '.' and '*'. DP: public class Solution { publ ...

  4. No.010:Regular Expression Matching

    问题: Implement regular expression matching with support for '.' and '*'.'.' Matches any single charac ...

  5. Regular Expression Matching

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  6. 【leetcode】Regular Expression Matching

    Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...

  7. 【leetcode】Regular Expression Matching (hard) ★

    Implement regular expression matching with support for '.' and '*'. '.' Matches any single character ...

  8. grep(Global Regular Expression Print)

    .grep -iwr --color 'hellp' /home/weblogic/demo 或者 grep -iw --color 'hellp' /home/weblogic/demo/* (-i ...

  9. 66. Regular Expression Matching

    Regular Expression Matching Implement regular expression matching with support for '.' and '*'. '.' ...

  10. Jmeter组件4. Regular Expression Extractor

    位置:Post-Processors - Regular Expression Extractor 所谓的Post-Processors直译为后处理器,意思是在域内所有Sampler执行完后才会执行, ...

随机推荐

  1. reduce 之 mixin实现

    语法: arr.reduce(callback[, initialValue]) 参数:    callback:执行数组中每个值的函数,包含四个参数:    accumulator:累加器累加回调的 ...

  2. spring学习 十二 AspectJ-based的通知入门 带参数的通知

    第一步:编写通知类 package com.airplan.pojo; import org.aspectj.lang.ProceedingJoinPoint; public class Advice ...

  3. 网上流行的linux内核漫画

  4. mysql主从配置思路

    记录一下 原文:http://www.rjfw.com.cn/qamain/prevView.action?id=40482017200000031 mysql主从配置(清晰的思路) mysql主从配 ...

  5. git .gitignore未生效

    添加进.gitignore的问题未生效. .gitignore只会忽略在.gitignore编写之后的未跟踪(untrack)文件,而在编写.gitignore之前已经add and commit的文 ...

  6. SHELL脚本取系统当前年月日问题 (去0)

    1. #!/bin/bash tmonth=`date +%m`tyear=`date +%y`tday=`date +%d`day=`expr $tday + 0`month=`expr $tmon ...

  7. springboot同时使用thymeleaf和jsp模板

    语言:javaEE 框架:springboot+thymeleaf.jsp模板引擎 背景:学习springboot过程中想同时使用thymeleaf和jsp访问(官方不建议) 步骤: 1)  在pom ...

  8. 牛客训练四:Applese 涂颜色(费马小定理+快速幂)

    题目链接:传送门 思路: 考虑每一列有2种颜色,总共有n行,每一行的第一个格确定颜色,由于左右颜色不相同,后面的行就确定了. 所以总共有2^n中结果. 由于n太大,所以要用到费马小定理a^n%mod= ...

  9. 3-具体学习git--reset回到过去的版本(commit间穿梭),checkout单个文件穿梭

    git log --oneline 命令可以在一块儿显示做过的改动. 我在change 2时忘了一条,想在change 1后再添加一个语句或一个操作,然后这个状态再提交仍作为change 2.将这个s ...

  10. go语言判断末尾不同的长字符串的方法

    判断两种末尾不同的长字符串,在使用正则表达式的基础上,进一步利用好字符串的方法,最后成功对问题进行解决. package utils import ( "io/ioutil" &q ...