Page 1 of 1

Calling all regex gurus

Posted: Wed Nov 15, 2006 9:05 am
by LeMerovingian
having a tough time trying to figure this one:

here are the samples i would like to match on (match items in bold)....

http://www.mydomain.com/[b]somepage[/b] (basically anything that comes after the "/" slash)
http://www.mydomain.com/[b]somepage[/b]

However, I don't want to match anything with a .php extension or with nothing after the "/". ie...

http://www.mydomain.com
http://www.mydomain.com/index.php
http://www.mydomain.com
http://www.mydomain.com/index.php

Posted: Wed Nov 15, 2006 9:12 am
by timvw
Next time use a subject that says something about your actual problem...

[^abc] would match everything exepct a, b or c.. I presume you can take it from here...

Posted: Fri Dec 08, 2006 4:10 pm
by kaisellgren
Well I would do the following:

Code: Select all

$str = "http://www.sdfsdf.com/dfssdf.php";
$ending = preg_replace("~(?:(?:(?://)?.*?/))~","",$str);
if (preg_match("~\.~",$ending))
 echo "no return";
else
 echo "the returnable variable value is $ending";