首页 > 科技 > Regular Expressions

Regular Expressions

2006年2月8日 10点46分 发表评论 阅读评论

The Regular Expressions is collection which include some regular or non regular characters.The following characters are listed here:
^ : only match the first character of line
$ : only match the last character of line
* : match all of the following strings
[] : match some characters, they would be declared in an identified range.For example, [0-9] means it would be match with any number from 0 to 9.
: used to specify the regular character. eg, “$” means “$” in RE.
. : match only one character.
pattern{n} : matched the lines in which pattern’s number is n.
pattern{n,}m : the least time would be m.
pattern{n,m} : match times between “n” and “m”.
eg:
dd-mm-yyyy : [0-9]{2}-[0-9]{4}-[0-9][4]
ip address: xxx.xxx.xxx.xxx
[0-9]{3}.[0-9]{3}.[0-9]{3}.[0-9]{3}

The difference between good codes and wonderful codes is depended on using RE rightly.

分类: 科技 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
您必须在 登录 后才能发布评论.