Regexp not working in PHP?

sjamms

New member
I am trying to validate my form input on my site using a regexp. I'm using RegexBuddy to create and test it - and it works... in the program. When I transfer it to my PHP file, it doesn't. The field is for their name, therefore I want to allow only: Aa-Zz, 0-9 (for "the 3rd", etc. if desired), a space character, and an apostrophe. It tests positive in RegexBuddy, but not when transferred to my site. I also tried switching the flavor to
POSIX and using ereg, but not success.

Here is the code:

if (preg_match('/^[A-Za-z0-9 \']+$/m', $fname)) {
# Successful match
} else {
# Match attempt failed
}
 
Back
Top