在使用JAVA中的正则表达式主要有两个类,一个是Pattern类,一个是Matcher类。
使用步骤如下
Pattern p = Pattern.compile(regExp);
Matcher m = p.matcher(string);
后面做的是先要调用m.find()函数然后再调用m.group()函数。因为调用了m.find()函数以后才开始查找过程。所以没有调用m.find()直接调用m.group()会产生
Exception in thread "main" java.lang.IllegalStateException: No match found异常
| 广告合作:400-664-0084 全国热线:400-664-0084 Copyright 2010 - 2017 www.my8848.com 珠峰网 粤ICP备15066211号 珠峰网 版权所有 All Rights Reserved
|