正则表达式加注释用法
2011-08-31 11:13
197 查看
regex_1:\d{4}-\d{2}
test文本:2011-08
结果:全部可以命中!
加注释后:
regex_2:
(?x)\d{4}#year:comment
-
\d{2}#month:comment
都可以命中!
分析:
使用了修饰符:(?x)--->使得可以宽松排列
使用了注释符:#--->后加注释内容
Match the remainder of the regex with the options: free-spacing (x) «(?x)»
Match a single digit 0..9 «\d{4}»
Exactly 4 times «{4}»
Comment: #year:comment «#year:comment»
Match the character “-” literally «-»
Match a single digit 0..9 «\d{2}»
Exactly 2 times «{2}»
Comment: #month:comment «#month:comment»
test文本:2011-08
结果:全部可以命中!
加注释后:
regex_2:
(?x)\d{4}#year:comment
-
\d{2}#month:comment
都可以命中!
分析:
使用了修饰符:(?x)--->使得可以宽松排列
使用了注释符:#--->后加注释内容
Match the remainder of the regex with the options: free-spacing (x) «(?x)»
Match a single digit 0..9 «\d{4}»
Exactly 4 times «{4}»
Comment: #year:comment «#year:comment»
Match the character “-” literally «-»
Match a single digit 0..9 «\d{2}»
Exactly 2 times «{2}»
Comment: #month:comment «#month:comment»
相关文章推荐
- JDK5.0中注释(Annotation)的用法
- 正则表达式用法与介绍
- hibernate用法注释积累
- 正则表达式grep用法详解
- JSP注释及三种scriptlet的用法
- php DOC类型注释的用法
- JDK5 Annotation(注释)的用法
- php DOC类型注释的用法
- myeclipse 中 TODO 注释的用法
- Xcode代码中特殊的注释技术——TODO、FIXME和XXX的用法
- grep用法详解:grep与正则表达式
- 不同版本IE使用不同css(css条件注释语句用法)
- java笔记(四)[java中的import关键词&java中的javadoc用法及注释说明&java中的final关键字&java中的内部类详解]
- 正则表达式的基本用法说明
- 正则表达式去除网页注释
- 正则表达式基础用法
- java中自定义注释@interface的用法
- Shell脚本学习(三)注释的用法
- visual assist x 注释用法
- php DOC类型注释的用法