fork download
  1. <?php
  2.  
  3. $arr = ["first-second",
  4. "first second",
  5. "first'second",
  6. "first & second",
  7. "first&second",
  8. "first(second)",
  9. "first (second)",
  10. "first-second-third",
  11. "first second third",
  12. "first second third(fourth)",
  13. "first-second-third(fourth)",
  14. "word Castaٌeda",
  15. "Alfonso Lista (Potia)",
  16. "Bacolod-Kalawi (Bacolod-Grande)",
  17. "Balindong (Watu)",
  18. "President Manuel A. Roxas",
  19. "Enrique B. Magalona (Saravia)",
  20. "Bacolod-Kalawi (Bacolod-Grande)",
  21. "Datu Blah T. Sinsuat",
  22. "Don Victoriano Chiongbian (Don Mariano Marcos)",
  23. "Bulalacao (San Pedro)",
  24. "Hinoba-an (Asia)"];
  25. $pattern = "~^\p{L}[\p{L}\p{M}\h().'&-]*$~u";
  26. foreach ($arr as $s) {
  27. echo $s;
  28. if (preg_match($pattern, $s)) {
  29. echo " => VALID\n";
  30. } else {
  31. echo " => INVALID\n";
  32. }
  33. }
Success #stdin #stdout 0.02s 23940KB
stdin
Standard input is empty
stdout
first-second => VALID
first second => VALID
first'second => VALID
first & second => VALID
first&second => VALID
first(second) => VALID
first (second) => VALID
first-second-third => VALID
first second third => VALID
first second third(fourth) => VALID
first-second-third(fourth) => VALID
word Castaٌeda => VALID
Alfonso Lista (Potia) => VALID
Bacolod-Kalawi (Bacolod-Grande) => VALID
Balindong (Watu) => VALID
President Manuel A. Roxas => VALID
Enrique B. Magalona (Saravia) => VALID
Bacolod-Kalawi (Bacolod-Grande) => VALID
Datu Blah T. Sinsuat => VALID
Don Victoriano Chiongbian (Don Mariano Marcos) => VALID
Bulalacao (San Pedro) => VALID
Hinoba-an (Asia) => VALID