Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean validateAntifakeId(String s) { boolean tag = true; final String pattern1 = "^[0-9]{18,18}$"; Pattern pattern = Pattern.compile(pattern1); Matcher matcher = pattern.matcher(s); if (s == null || !matcher.matches()) { tag = false; } return tag; } }