webdev007
Programmer
- Sep 9, 2005
- 168
I am not much of regex educated person (understatement)
I am trying to remove everything after .com. .net. .org. .edu.
or
after .com/ .net/ .org/ .edu/
In cases where each of them could end by a "dot" or by a "slash"
here is my trial:
$url="
$search_for = array("$del = array("");
$new_url2 = str_replace($search_for, $del, $url);
//$new_url2=rtrim($new_url, '*');
//$new_url=$new_url2;
echo"first echo: $new_url2<br>";
// the above works fine ( del the http:// part) then it does not work!...
$regex ="( (.com\/|.net\/|.org\/|.edu\/|.com.|.net.|.org.|.edu.)?([^\/:]+)/ )";
if
(preg_replace($regex, "", $new_url2))
{
print $new_url2 . "<br>\n";
}
I am trying to remove everything after .com. .net. .org. .edu.
or
after .com/ .net/ .org/ .edu/
In cases where each of them could end by a "dot" or by a "slash"
here is my trial:
$url="
$search_for = array("$del = array("");
$new_url2 = str_replace($search_for, $del, $url);
//$new_url2=rtrim($new_url, '*');
//$new_url=$new_url2;
echo"first echo: $new_url2<br>";
// the above works fine ( del the http:// part) then it does not work!...
$regex ="( (.com\/|.net\/|.org\/|.edu\/|.com.|.net.|.org.|.edu.)?([^\/:]+)/ )";
if
(preg_replace($regex, "", $new_url2))
{
print $new_url2 . "<br>\n";
}