Jump to content

eregi to match url


jmurch

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.