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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

c# - Create a Notification Object (Email or Page) At Run Time -- Dependency Injection or Factory -

Set Up Of Common Name Of SSL Certificate To Protect Plesk Panel -