public class Isnum { public static void main(String[] args) throws Exception { String num = "hello"; String regex = "\\w{6,15}"; System.out.println(num.matches(regex)); } }