Java tutorial
//package com.java2s; public class Main { public static boolean isValid_id(String str) { String regex1 = "[0-9]{17}x"; String regex2 = "[0-9]{15}"; String regex3 = "[0-9]{18}"; return str.matches(regex1) || str.matches(regex2) || str.matches(regex3); } }