-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEx 10.java
More file actions
33 lines (23 loc) · 823 Bytes
/
Ex 10.java
File metadata and controls
33 lines (23 loc) · 823 Bytes
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
import java.util.Scanner;
import java.util.regex.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String mail = sc.next();
String phone = sc.next();
Pattern id = Pattern.compile("^\\w+([.-]?\\w+)*@[a-zA-Z\\d]*\\.[a-zA-Z]{3}$");
Matcher match = id.matcher(mail);
if(match.find())
System.out.println("True");
else
System.out.println("False");
Pattern number = Pattern.compile("^(0|0098|\\+98)9(0[1-5]|[1 3]\\d|2[0-2]|98)\\d{7}$");
Matcher match2 = number.matcher(phone);
if(match2.find())
System.out.println("True");
else
System.out.println("False");
}
}