Sorry for the basic question, I did a search and found nothing.
I am wanting to allow form input of hypenated names, like "Joe-Bob Roper, Jr.". how do you add the hypen to this regex?
if (!ereg("[a-zA-Z\,. ]+$", $Name)) { print_error("Your name:<br><b>$Name</b><br>...contains characters that cannot be accepted."); } Thanks for your help, --ph
if you want to put "]" or "-" into a character class, you can either 1) escape them, or 2) put them at the front of the class where they would otherwise have no meaning.
-- rad
Thanks rad, I tried to to what you suggest (escaped) this way, and it did not work:
(!ereg("-[a-zA-Z\,. ]+$", $Name))
and...
(!ereg("-[a-z-A-Z\,. ]+$", $Name))
I need some help with the syntax here. I feel like a rank beginner.
--ph
try
(!ereg("[-a-zA-Z,. ]+$", $Name))
Works!
Thanks rad. Again, I was trying to make things overly difficult.