`

java 正则表达式4

阅读更多
public static void main(String[] args) {
		String input="aaa bbbb ffffff 999999999";
		Pattern p=Pattern.compile("(\\w)((?=\\1\\1\\1)(\\1))+");
		Matcher m=p.matcher(input);
		while(m.find()){
			System.out.println(m.group()+"   "+m.start()+"->"+m.end());
		}
	}

 

输出结果

 

bb   4->6
ffff   9->13
9999999   16->23

 

 

原因解释:

   http://topic.csdn.net/u/20081224/20/450c914e-384b-4930-b3e3-9580be66bfbb.html

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics