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 Link to comment https://forums.phpfreaks.com/topic/166977-google-analytics-regex-match-help/ 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). Link to comment https://forums.phpfreaks.com/topic/166977-google-analytics-regex-match-help/#findComment-880355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.