SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Location
    Kansas
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    preg_match regular expression Zip code

    Sanity check. I've had a brain fart and I'm getting
    PHP Code:
    PHP Warning:  preg_match(): Unknown modifier ']' 
    Here is the test code. What am I missing in my regular expression?

    PHP Code:
    echo preg_match('/^[0-9]{5}([- /]?[0-9]{4})?$/'"52461"); 

  2. #2
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe you need to escape the '/' (try \/ instead of /)

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Location
    Kansas
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sharedlog.com View Post
    Maybe you need to escape the '/' (try \/ instead of /)
    Nice catch! Totally missed it. Thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •