https://www.codewars.com/kata/55d5434f269c0c3f1b000058/train/javahtml
package codewars; import java.util.regex.*; public class Kata{ public static int TripleDouble(long num1, long num2){ String str1 = String.valueOf(num1); String str2 = String.valueOf(num2); String regex = ".*(\\d)\\1{2}.*"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher(str1); String d = ""; while(matcher.find()){ d = matcher.group(1); } if("".equals(d)){ return 0; }else{ return str2.matches(String.format(".*%s{2}.*",d)) ? 1 : 0; } } }
How to match repeated digits using a regular expressionjava
http://blog.sina.com.cn/s/blog_6154bf970100svhz.htmlgit
Java regex group: http://blog.csdn.net/qinggreen/article/details/9139847#express