#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2007
    Posts
    104
    Rep Power
    43

    Php preg_match Regex not working correctly


    I have the regex pattern ^[A-Za-z' -]{1,50}$ it works fine apart from it doesnt allow ' even though some software im using (The Regex Coach) says it should allow ' (e.g. o'reilly should be ok) but when I try to use it in php it returns an error. Here is the bit of PHP code im using:

    PHP Code:
    if(preg_match("/^[A-Za-z' -]{1,50}$/",$fname)){


    }else{ 
    $dont_send=1; echo "First Name Must be a-z or A-Z only<br />";} 
    This should allow a-z,A-Z,-,' and spaces
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,119
    Rep Power
    9398
    Works fine for me. What's the rest of the code?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2007
    Posts
    104
    Rep Power
    43
    Hi requinix - problem solved the magic_quote thing was on that adds / to ' didn't even know it was on tbh. Next step is to allow international characters like and all the other letter types. Any ideas how to do this?

IMN logo majestic logo threadwatch logo seochat tools logo