星空网 > 软件开发 > Java

pattern与matcherr

package 排序相关;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ArraySort {
public static void main(String[] args) {
/**
* m.find()没调用一次,游标加一
* m.groupcount()得到的是当前m.find()得到的当前组的组数,本例是两个,即([a-z]+)和(\\d+)")两个
*/
Pattern p=Pattern.compile("([a-z]+)(\\d+)");//m.groupcount()=2
// Pattern p=Pattern.compile("([a-z]+)(\\d+)(\\d+)"); //m.groupcount()三个
Matcher m=p.matcher("sasa678aaa8089aaa5768");
// System.out.println(m.find()); ///匹配aaa2223
System.out.println(m.groupCount()); //返回0,因为没有
while (m.find()) {
System.out.println(m.start()); 
// System.out.println(m.start(2)); 
System.out.println(m.end());
// System.out.println(m.end(2)); 
System.out.println(m.group()); 
// System.out.println(m.group(2));
}
}
输出:

2
0
7
sasa678
7
14
aaa8089
14
21
aaa5768




原标题:pattern与matcherr

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

用什么加速器才能看tiktok:https://www.goluckyvip.com/tag/81158.html
tiktok官网免费下载:https://www.goluckyvip.com/tag/81159.html
沃尔玛供应商:https://www.goluckyvip.com/tag/8116.html
tiktok国际官网:https://www.goluckyvip.com/tag/81160.html
tiktok在中国怎么才能看:https://www.goluckyvip.com/tag/81161.html
tiktok下载安卓:https://www.goluckyvip.com/tag/81162.html
珠海附近过年旅游景点 珠海附近过年旅游景点免费:https://www.vstour.cn/a/408243.html
韶关有组团到山西旅游 韶关到山西有多少公里:https://www.vstour.cn/a/408244.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流