Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
import java.util.regex.*;
public class Main {
public static boolean isValid(String s)
{
Pattern p=Pattern.compile("(0|\\+91[\\s])?[7-9][0-9]{9}");
Matcher m=p.matcher(s);
return (m.find() && m.group().equals(s));
}
public static void main(String args[]) {
String str="+91 9415074505";
if(isValid(str))
{
System.out.println("It is a valid mobile number");
}
else
{
System.out.println("It is invalid mobile number");
}
}
}
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more