public class RegexDemo {
public static boolean verifyPhoneno(String input){
boolean ck=false;
String regex=" \\b0?(1[38]\\d{9})|d{9}|(15[89]\\d{8})\\b";
Pattern pattern=Pattern.compile(regex);
Matcher matcher=pattern.matcher(input);
if(matcher.matches()){
ck=true;
}
return ck;
}
public static boolean verifyID (String input) {
boolean ck=false;
String regex15="^\\d{8}((0\\d)|(1[0-2]))((3[01])|([0-2]\\d))\\d{3}$";
String regex18="^\\d{6}((1[89])|(2\\d))\\d{2}((0\\d)|(1[0-2]))((3[01])|([0-2]\\d))\\d{3}( \\d|X)$";
Pattern pattern=Pattern.compile(regex15);
Matcher matcher=pattern.matcher(input);
if(matcher.matches()){
ck=true;
}else {
pattern=Pattern.compile(regex18);
matcher=pattern.matcher(input);
if(matcher.matches())
{
ck=true;
}
}
return ck;
}
public static boolean verifyEmail(String input) {
boolean ck=false;
String regex=" \\w+@\\w+(\\.\\w+)+";
Pattern pattern=Pattern.compile(regex);
Matcher matcher=pattern.matcher(input);
if(matcher.matches()){
ck=true;
}
return ck;
}
public static boolean verifyPhoneno(String input){
boolean ck=false;
String regex=" \\b0?(1[38]\\d{9})|d{9}|(15[89]\\d{8})\\b";
Pattern pattern=Pattern.compile(regex);
Matcher matcher=pattern.matcher(input);
if(matcher.matches()){
ck=true;
}
return ck;
}
public static boolean verifyID (String input) {
boolean ck=false;
String regex15="^\\d{8}((0\\d)|(1[0-2]))((3[01])|([0-2]\\d))\\d{3}$";
String regex18="^\\d{6}((1[89])|(2\\d))\\d{2}((0\\d)|(1[0-2]))((3[01])|([0-2]\\d))\\d{3}( \\d|X)$";
Pattern pattern=Pattern.compile(regex15);
Matcher matcher=pattern.matcher(input);
if(matcher.matches()){
ck=true;
}else {
pattern=Pattern.compile(regex18);
matcher=pattern.matcher(input);
if(matcher.matches())
{
ck=true;
}
}
return ck;
}
public static boolean verifyEmail(String input) {
boolean ck=false;
String regex=" \\w+@\\w+(\\.\\w+)+";
Pattern pattern=Pattern.compile(regex);
Matcher matcher=pattern.matcher(input);
if(matcher.matches()){
ck=true;
}
return ck;
}