getting really annoying one url will work where another one wont
//$formatted_url = preg_replace("/\b((http(s?):\/\/)|(www\.))\b/i", "",
$url);
//$formatted_url =
preg_replace("/\b((http(s?):\/\/)|(www\.))([\w\.]+)([\/\w+\.]+)\b/i", "$5",
$url);
$formatted_url = eregi_replace("^(.{2,6}://)?([^:]*)?([^/]*)?(.*)",
"\\2",
$url);
tried all these dont work
some urls will have http://www. some will only have www. some will have
:1023 for forced ports and they all will have /directory afterwards i just
need domain.com for example :|
-----Original Message-----
From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 21, 2002 7:48 AM
To: [EMAIL PROTECTED]; electroteque; [EMAIL PROTECTED]
Subject: Re: [PHP] preg_replace question
> --- electroteque <[EMAIL PROTECTED]> wrote:
> > how could i remove http://www. ot of a url string using
> preg_replace?
>
> No need to reinvent the wheel for this. Just use parse_url() instead:
>
> http://www.php.net/manual/en/function.parse-url.php
>
Or just str_replace(). No need for regular expressions.
http://www.php.net/manual/en/function.str-replace.php
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php