Problematic Preg Match

Discussion in 'PHP' started by Galaxian, Mar 23, 2012.

  1. #1
    The preg_match below is supposed to find matches in $_SERVER['request_uri'] that look like a directory, i.e /test-page/, but it always returns false/0. What's the problem? The same test works on http://www.functions-online.com/preg_match.html.

    preg_match($_SERVER['REQUEST_URI'],'/^\/([a-z0-9-_]+)\//')
    PHP:
     
    Galaxian, Mar 23, 2012 IP
  2. TakeReal.com

    TakeReal.com Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Should be another order, at least:

    preg_match('/^\/([a-z0-9-_]+)\//', $_SERVER['REQUEST_URI'])
     
    TakeReal.com, Mar 24, 2012 IP
  3. Galaxian

    Galaxian Active Member

    Messages:
    246
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #3
    I'm a douchebag. Thanks!
     
    Galaxian, Mar 24, 2012 IP