import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "^\\+?([87](?!95[4-79]|99[08]|907|94[^0]|336|986)([348]\\d|9[0-6789]|7[0247])\\d{8}|[1246]\\d{9,13}|68\\d{7}|5[1-46-9]\\d{8,12}|55[1-9]\\d{9}|55[12]19\\d{8}|500[56]\\d{4}|5016\\d{6}|5068\\d{7}|502[45]\\d{7}|5037\\d{7}|50[4567]\\d{8}|50855\\d{4}|509[34]\\d{7}|376\\d{6}|855\\d{8}|856\\d{10}|85[0-4789]\\d{8,10}|8[68]\\d{10,11}|8[14]\\d{10}|82\\d{9,10}|852\\d{8}|90\\d{10}|96(0[79]|17[01]|13)\\d{6}|96[23]\\d{9}|964\\d{10}|96(5[69]|89)\\d{7}|96(65|77)\\d{8}|92[023]\\d{9}|91[1879]\\d{9}|9[34]7\\d{8}|959\\d{7}|989\\d{9}|97\\d{8,12}|99[^4568]\\d{7,11}|994\\d{9}|9955\\d{8}|996[57]\\d{8}|9989\\d{8}|380[3-79]\\d{8}|381\\d{9}|385\\d{8,9}|375[234]\\d{8}|372\\d{7,8}|37[0-4]\\d{8}|37[6-9]\\d{7,11}|30[69]\\d{9}|34[67]\\d{8}|3[12359]\\d{8,12}|36\\d{9}|38[1679]\\d{8}|382\\d{8,9}|46719\\d{10})$";
final String string = "";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
if (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html