PHP - Regex - Validation for name field - Detect if user enters '&' or 'and' -
PHP - Regex - Validation for name field - Detect if user enters '&' or 'and' -
i trying utilize regex observe when user enters "bob & jane" or "bob , jane".
i have tried next , of them trigged when "andy" or "andrew" entered:
/^[a-za-z]( & | , )[a-za-z]$/ /(" "and" "|" "&" ")/ /( , | & )/
(i tried these , without '^'
, '$'
)
thank in advanced thoughts!
the sec approach seems quotes confuse regex engine. utilize whitespace token instead:
/[a-z]+(\sand\s|\s&\s)[a-z]+/
php regex forms validation preg-match
Comments
Post a Comment