Results 1 to 1 of 1

Thread: Pattern Invalidated by Ending $ Anchor

  1. #1
    Join Date
    Jul 2006
    Posts
    497
    Thanks
    8
    Thanked 70 Times in 70 Posts

    Question Pattern Invalidated by Ending $ Anchor

    EDIT: Hmm, maybe I've lost my sense of sufficient testing during my hiatus... The / (slash) in the regex represents a variable substition, the value of which is the first character in another variable. The other variable contains an empty string. Lesson learned: Specific requirements are very good debugging tools.

    Grr... It works there but not on my localhost (PHP v5.2.6-3ubuntu4.1). It's supposed to match *nix paths, and it actually works without the ending $. But I want to specify that the whole string should be matched, because you never know when a freak case will blow your assumption to pieces.

    The pattern:
    {^[.a-z0-9_\-]*(/[.a-z0-9_\-]*)+$}i

    Test cases:
    • /lib
    • /var/www (only used on the above site because a design decision makes my script not use it anymore)


    The test cases contain nothing after the printable characters. Why in the world does that dollar sign matter so much? I'm also curious why my server cares but theirs doesn't, but you probably can't answer that.

    Thanks.
    Last edited by Jesdisciple; 06-07-2009 at 03:27 AM.
    -- Chris
    informal JavaScript student of Douglas Crockford
    I like wikis - a lot.

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
  •