[Solved] Phone number validation regex for length and numeric values [duplicate]


Try the regular expression

^\\d{10,15}$

Here \d is a predefined character class for digits
{10, 15} quantifier stands for a repeat of 10 to 15 times of the previous pattern

Ex:

String input = "1234567890";
Pattern pattern = Pattern.compile("^\\d{10,15}$");
if (pattern.matcher(input).find()) {
    System.out.println("Valid");
}

0

solved Phone number validation regex for length and numeric values [duplicate]