❮ Previous Next ❯

Java Regular Expression Mobile No Validation


Write a java program to check whether a given number is a valid mobile number or not

import java.util.regex.*;
class RegexDemo6
{
public static void main(String[] args)
{
Pattern p=Pattern.compile("(0/91)?[7-9][0-9]{9}");
Matcher m=p.matcher(args[0]);
if(m.find() && m.group().equals(args[0]))
{
System.out.println("valid mobile number");
}
else
{
System.out.println("invalid number");
}
}
}
Output:
1st run : java RegexDemo6 9439202111
valid mobile number
2nd run : java RegexDemo6 929292929292
invalid number

Java Regular expression program to check whether a given mail id is valid or invalid mail id.


❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved