nikefido Posted July 22, 2009 Share Posted July 22, 2009 Hi - Google anlaytics lets you match URLs in order to set a goal. For instance, this is a goal for us that lets us know someone successfully submitted a contact form: /[somefilename].php/submit1=true We need to match the [somefilename] with any text (valid file name). Currently we have: /[A-Za-z0-9_].php?submit1=true However, this isn't working. variations include: /^[A-Za-z0-9_]$.php?submit1=true ^\/[A-Za-z0-9_]\.php?submit1=true$ and others... The Filenames don't have special characters, do contain underscores and are mixed case. For some reason I can't get this seemingly simple regex match to work (Been testing with PHP's eregi / preg_match functions) Can anyone help match this pattern successfully? Thanks Quote Link to comment Share on other sites More sharing options...
thebadbad Posted July 22, 2009 Share Posted July 22, 2009 preg_match('~^/[A-Za-z0-9_]+\.php\?submit1=true$~D', $url); Notice the + quantifier, meaning one or more of the previous character (a character class matches one character), and that I escaped the special characters (the dot and the question mark). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.