Implement regex on phone number checking

This commit is contained in:
2025-10-01 20:59:18 +07:00
parent 82f8db5114
commit d29fc9b7e8

View File

@@ -25,6 +25,7 @@ public class Main{
ArrayList<WorkContact> wc = new ArrayList<WorkContact>(); ArrayList<WorkContact> wc = new ArrayList<WorkContact>();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, System.console().charset())); BufferedReader br = new BufferedReader(new InputStreamReader(System.in, System.console().charset()));
MatchyMatcher matcher = new MatchyMatcher("(\\+*)\\d{11}");
char ch = 0; char ch = 0;
@@ -72,13 +73,15 @@ public class Main{
; ;
} }
System.out.println("Введите номер: "); do{
System.out.println("Введите корректный номер телефона: ");
try{ try{
number = br.readLine(); number = br.readLine();
} }
catch(IOException e){ catch(IOException e){
; ;
} }} while(matcher.Match(number) == false);
switch(type){ switch(type){
case("Personal"):{ case("Personal"):{
@@ -264,7 +267,7 @@ public class Main{
Callable target = null; Callable target = null;
System.out.println("Введите имя искомого пользователя: "); System.out.println("Введите имя пользователя: ");
try{ try{
name = br.readLine(); name = br.readLine();
@@ -295,7 +298,7 @@ public class Main{
Emailable target = null; Emailable target = null;
System.out.println("Введите имя искомого пользователя: "); System.out.println("Введите имя пользователя: ");
try{ try{
name = br.readLine(); name = br.readLine();
@@ -327,4 +330,4 @@ public class Main{
} }
} }
} }
} }