I need to check the user input to make sure that the first name, last name (etc.) are entered correctly and are valid. I have to create a regular expression that checks if the user enters duplicate letters in the first name, last name, etc.
Example:
Is there a PHP regular expression to catch these cases? (I have a basic knowledge of regular expression, but for me it is too much)
EDIT: It should also contain the numbers: David 3 or III
thank
.
preg_match('/(\w)(\1+)/', $subject, $matches); print_r($matches);
\1 , \w.
\1
\w
, , - ?
$charCountArray = array(); foreach ($name as $char) { $charCountArray[$char]++; }
- , , PCRE .
: preg_match , , preg_match_all
preg_match
preg_match_all
:
/(\w)\1{2}/