Page 1 of 1

[Solved] splitting a URL

Posted: Tue Feb 07, 2006 7:15 pm
by sulen
I have a URL string like this

////192.168.1.247/htdocs/20061/DC101_20061/DEN/Homeworks/Incoming/reportee.reportee.reportee

I only want the part after the IP address like this

htdocs/20061/DC101_20061/DEN/Homeworks/Incoming/reportee.reportee.reportee

I tried using a parse_url to break it down but it doesnt recognise IP. So can someone help me with this. Any help will be greatly appreciated. Thanks

Posted: Tue Feb 07, 2006 7:25 pm
by feyd
it would if that were a qualified URL. That appears to be a Windows networking name.

try something like this

Code: Select all

$path = preg_replace('#^.+?[^/] /#','',$url);

Posted: Tue Feb 07, 2006 7:31 pm
by sulen
I used the following code

Code: Select all

$url = "////192.168.1.247/htdocs/20061/DC101_20061/DEN/Homeworks/Incoming/reportee.reportee.reportee";
$path = preg_replace('#^.+?[^/] /#','',$url);
echo $path;
The output it gave was

////192.168.1.247/htdocs/20061/DC101_20061/DEN/Homeworks/Incoming/reportee.reportee.reportee

I guess soemthing is wrong. Thx

Posted: Tue Feb 07, 2006 7:33 pm
by feyd
damned stupid pluses... :evil:

Code: Select all

$path = preg_replace('#^.+?[^/]+/#','',$url);

Posted: Tue Feb 07, 2006 7:35 pm
by sulen
Thank you sir it did work indeed.

Posted: Wed Feb 08, 2006 2:42 am
by m3mn0n
Gatta love the power of regex. :)