Java tutorial
//package com.java2s; public class Main { public static boolean personIdValidation(String text) { boolean flag = false; String regx = "[0-9]{17}x"; String reg1 = "[0-9]{15}"; String regex = "[0-9]{18}"; flag = text.matches(regx) || text.matches(reg1) || text.matches(regex); return flag; } }