Page 2 of 2
Posted: Fri Jan 07, 2005 3:26 am
by feyd
it does actually require some matching to protect it from fiddling...
Posted: Fri Jan 07, 2005 6:43 pm
by videogame
lets say the link says
http://www.website.com/index.html
the script identifies that it ends in .html
how can i make it so that it deletes whatever is between the / and the .html so that only
http://www.website.com is left?
Posted: Fri Jan 07, 2005 6:50 pm
by feyd
Code: Select all
preg_replace('#(?<!/)/.*$#', '', $value);
Posted: Fri Jan 07, 2005 7:49 pm
by videogame
this does not work because it is deleting too much.
for example, my test script, simply outputs "
http:"
Code: Select all
<?php
$value = "http://www.google.com/images/hello.html";
$value = preg_replace('#(?<!/)/.*$#', '', $value);
print $value
?>
Posted: Fri Jan 07, 2005 8:03 pm
by feyd
as I said, untested.
Posted: Fri Jan 07, 2005 8:21 pm
by feyd
Code: Select all
<?php
$value = "http://www.google.com/images/hello.html
http://www.google.com/test/test.html";
$value = preg_replace('#(://.*?)?/.*$#m', '\\\\1', $value);
print $value;
?>
Posted: Fri Jan 07, 2005 8:51 pm
by videogame
this outputs
http://www.google.com but i would like it to output
http://www.google.com/images/ instead... so simply take out the hello.html
Posted: Fri Jan 07, 2005 8:56 pm
by feyd
try to figure it out. We're not here to do all the work for you.
Posted: Sat Jan 08, 2005 12:52 am
by John Cartwright
As feyd said give it a try, post some more code, and well point out your mistakes and how you can improve your code