fork(2) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.Matcher;
  7. import java.util.regex.Pattern;
  8.  
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. String sPhoneNumber = "+359875123456";
  16. //String sPhoneNumber = "605-88899991";
  17. //String sPhoneNumber = "605-888999A";
  18.  
  19. Pattern pattern = Pattern.compile("^(((\\+|00)359)|0)8[7-9][2-9][0-9]{6}$");
  20. Matcher matcher = pattern.matcher(sPhoneNumber);
  21.  
  22. if (matcher.matches()) {
  23. System.out.println("Phone Number Valid");
  24. }
  25. else
  26. {
  27. System.out.println("Phone Number Not Valid");
  28. }
  29. }
  30. }
Success #stdin #stdout 0.05s 711168KB
stdin
Standard input is empty
stdout
Phone Number Valid