regex强大工具:org.apache.oro.text.regex中的MatchResult
来源:互联网 发布:网络游戏美工教程 编辑:程序博客网 时间:2024/06/06 05:38
MatchResult可以这样理解就是匹配了regex pattern的String和一些状态项的结合体。
但是有两点需要注意的:
1、经常使用到的:
result = matcher.getMatch();
返回的MatchResult是这次使用contains时所得的结果。下次再调用新一轮的contains(),然后再使用getMatch()返回的会是新一轮的结果。
2、一个概念的理解:group
所谓的group就是在pattern regex中使用到的分组。
比如说,一个regex为:(\d+)(abc)
“(\d+)”match出来的结果就是对应:group 1
而“(abc)”match出来的结果就是对应:group 2
group 0指代整个匹配。其中,result.group(0)的使用效果与result.tostring()一样。
除此之外,还有一点需要注意的,group的组数:至少为1(因为至少包括整个匹配这种情况嘛!)
- regex强大工具:org.apache.oro.text.regex中的MatchResult
- regex强大工具:org.apache.oro.text.regex中的PatternMatcherInput使用
- regex强大工具:org.apache.oro.text.regex中的PatternMatcher使用之contains()与matchs()的区别
- regex强大工具:org.apache.oro.text.regex下的Util源码解读之substitute()方法1
- org/apache/oro/text/regex/MalformedPatternException
- org/apache/oro/text/regex/MalformedPatternException
- 解决:ClassNotFoundException: org.apache.oro.text.regex.MalformedPatternException
- Caused by: java.lang.ClassNotFoundException: org.apache.oro.text.regex.PatternCompiler
- Regex
- Regex
- Regex
- Regex
- regex
- Regex
- regex
- Regex
- regex
- Regex
- java中如何调用CMD命令 Java基础人员请关注。
- 开机没多久就重启进去省点模式
- HttpClient 教程 (六)
- 警告对话框
- HttpClient_4 用法 由HttpClient_3 升级到 HttpClient_4 必看
- regex强大工具:org.apache.oro.text.regex中的MatchResult
- js获取当前详细网址
- 最近有点时间-赶紧学习,好久没有写东西了
- 直方图均衡化
- Java 修改文件名
- IE6中png背景图片不透明的解决办法
- SmartGWT学习整理 2、理解核心中的核心DataSource
- 脑筋急转弯(上
- 缺陷描述是这样提高的