标签:
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.
标签:
原文地址:http://www.cnblogs.com/kid551/p/4177854.html