jmurch Posted July 26, 2008 Share Posted July 26, 2008 I need help on the proper syntax for a regex to match a URL that is captured via http_referer. I need my regex expression to match what would in wildcard sytax be: https://www.mysite.com/folder/* Not all that difficult but I can seem to get the sytax correct. TIA, Jeff Link to comment https://forums.phpfreaks.com/topic/116741-eregi-to-match-url/ Share on other sites More sharing options...
discomatt Posted July 26, 2008 Share Posted July 26, 2008 You want to put this in the regex forum... but what did you want to capute using the regex, only the wildcard? $subject = 'https://www.mysite.com/folder/some/thing/else.php'; preg_match('%\\Ahttps://www\\.mysite\\.com/folder/(.++)\\z%i', $subject, $match); print_r( $match ); Explanation of regex Assert position at the start of the string «\A» Match the characters "https://www" literally «https://www» Match the character "." literally «\.» Match the characters "mysite" literally «mysite» Match the character "." literally «\.» Match the characters "com/folder/" literally «com/folder/» Match the regular expression below and capture its match into backreference number 1 «(.++)» Match any single character that is not a line break character «.++» Between one and unlimited times, as many times as possible, without giving back (possessive) «++» Assert position at the very end of the string «\z» Link to comment https://forums.phpfreaks.com/topic/116741-eregi-to-match-url/#findComment-600352 Share on other sites More sharing options...
unkwntech Posted July 26, 2008 Share Posted July 26, 2008 I realy suggest that EVERYONE who might ever work with regex even once go get RegExBuddy, it will most certainly be your regex buddy =) http://www.regexbuddy.com/ Link to comment https://forums.phpfreaks.com/topic/116741-eregi-to-match-url/#findComment-600356 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.