java正则表达式彻底研究 (四)

2014-11-24 08:07:39 · 作者: · 浏览: 2
t.println("the:"+k++);
System.out.println(mmm1.find());
System.out.println(mmm1.end());
}catch(Exception e){
isEnd=true;
}
isEnd=false;
Pattern pp2=Pattern.compile(".*+foo");
Matcher mm2=pp2.matcher("xfooxxxxxxfoo");
/**
*
Possessive quantifiers
X + X, once or not at all
X*+ X, zero or more times
X++ X, one or more times
X{n}+ X, exactly n times
X(n,}+ X, at least n times
X{n,m}+ X, at least n but not more than m times
Possessive quantifiers 这种匹配方式与Greedy方式相似,所不同的是它不够聪明,当
它一口吃掉所有可以吃的字符时发现不匹配则认为整个串都不匹配,它不会试着吐出几个。它的行
为和大地主相似,贪婪但是愚蠢,所以名曰强占的。
*/

int ii=0;
System.out.println("+++++++++++++++++++++++++++");
System.out.println("xfooxxxxxxfoo");
while(isEnd==false)
try{
System.out.println("the:"+ii++);
System.out.println(mm2.find());
System.out.println(mm2.end());
}catch(Exception e){
isEnd=true;
}
}
}


作者 a442180673