码迷,mamicode.com
首页 > 其他好文 > 详细

Regular Expression

时间:2014-12-22 14:10:30      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

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 Expression

标签:

原文地址:http://www.cnblogs.com/kid551/p/4177854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!