Advertisement
NeverRIEght

Patterns

Dec 20th, 2023
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. Pattern phoneNumberPattern = Pattern.compile("^(\\+370)([0-9]{8})$");
  2.         Matcher phoneNumberMatcher = phoneNumberPattern.matcher("+37061370310");
  3.         boolean isPhoneNumberCorrect = phoneNumberMatcher.matches();
  4.  
  5.         System.out.println(isPhoneNumberCorrect);
  6.  
  7.         Pattern emailPattern = Pattern.compile("^(\\+370)([0-9]{8})$");
  8.         Matcher emailMatcher = phoneNumberPattern.matcher("+37061370310");
  9.         boolean isEmailCorrect = phoneNumberMatcher.matches();
  10.  
  11.         System.out.println(isPhoneNumberCorrect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement