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

RE0509

时间:2014-05-09 14:26:32      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:re

metacharacters relation to match:

   *:0-multi

   +:1-multi

   ?:0-1

   {n},{n,m},{n,}:the number of matching



string switch

   eg: pattern="lynn|coco"

       src1="hello,my name is lynn"

       result1="lynn"

       src2="hello,my name is coco"

       result2="coco"


ignore case

    eg:pattern="(?i)Lynn"

    src="hello,my name is lynn"

   result="lynn"


multi-repeat-character

   eg:pattern="n{2}"

   src="hello,my name is lynn"

   result="nn"


digital match

   eg:pattern="\d+"

   src="I am 24 years old but 18 years in school"

   result="24","18"

   

   eg:pattern="[0-9]+"

   src="I am 24 years old but 18 years in school"

   result="24","18"

   

optional character match

   eg:pattern="colou?r"

   src1="color"    result=color

   src2="colour"  result=colour






本文出自 “Fighting” 博客,请务必保留此出处http://lynnhome.blog.51cto.com/3654477/1408810

RE0509,布布扣,bubuko.com

RE0509

标签:re

原文地址:http://lynnhome.blog.51cto.com/3654477/1408810

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