Quote:
Originally Posted by PopSmith
I am thinking that my above use of preg_match would validate that the $c_fname variable, which is the sanitized output of the variable $first_name, contains only characters a-z in either upper or lower case as well as the period or underscore. The {1,15} would limit the preg_match to between 1 and 15 characters.
|
return preg_match("/^[a-zA-Z\._]{1,15}/")
I believe that's correct, although make sure you escape the period as shown above since it's a meta character. I'm not sure if you want the dollar-sign meta in there- it indicates matching at the end of the line (or before newline at the end) and I don't know if that's what you really want to do or not.
You might grab a copy of
Regex Buddy and give it a try, I find it invaluable in creating and working out regex strings.