java - Phone number validation regex for length and numeric values -


this question has answer here:

i have validate phone number based on following criteria,

it should take numeric values. minimum 10 , maximum 15 

how can write regular expression in java satisfying above? new regular expressions.

try regular expression

^\\d{10,15}$ 

here \d predefined character class digits
{10, 15} quantifier stands repeat of 10 15 times of previous pattern

ex:

string input = "1234567890"; pattern pattern = pattern.compile("^\\d{10,15}$"); if (pattern.matcher(input).find()) {     system.out.println("valid"); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -