-
Notifications
You must be signed in to change notification settings - Fork 0
/
EqualsIgnoreCase.java
32 lines (22 loc) · 1.05 KB
/
EqualsIgnoreCase.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class EqualsIgnoreCase {
public static boolean isValidEmailId(String emailId){
String specialAllowedChar="._#-'*";
// String regex2="(^[a-zA-Z0-9]+["+specialAllowedChar+"]?)+([a-zA-Z0-9]+["+specialAllowedChar+"]?)*([a-zA-Z0-9])+@(([a-zA-Z0-9]+[-]?)+[a-zA-Z0-9]+\\.)+([a-zA-Z0-9]+\\.)*([a-zA-Z]{2,4})$";
String regex2="(^[a-zA-Z0-9]+["+specialAllowedChar+"]?)+([a-zA-Z0-9]+["+specialAllowedChar+"]?)*([a-zA-Z0-9])+@(([a-zA-Z0-9]+[-]?)+[a-zA-Z0-9]+\\.)+([a-zA-Z0-9]+\\.)*([a-zA-Z]{2,4})$";
Pattern pattern = Pattern.compile(regex2);
System.out.println(regex2);
System.out.println(pattern);
Matcher mat = pattern.matcher(emailId);
if (mat.matches()) {
return true;
}
return false;
}
public static void main(String[] args) {
// String email="[email protected]";
String email="[email protected]";
System.out.println(isValidEmailId(email.trim()));
}
}