You are here: Re: Extract any URL from any string? « PHP Programming Language « IT news, forums, messages
Re: Extract any URL from any string?

Posted by deko on 02/12/07 20:58

Here's a possible way to validate a host's domain name(s):

$invalid = "(~ ` ! @ # $ % ^ & * ( ) _+ = { } [ ] \ | : ; " ' < > , ? /)"
//pseudo code
$url_a = parse_url($url);
$urlHost = $url_a['host'];
$urlHost_a = explode('.',$urlHost);
for ($i = count($urlHost_a) - 2; $i > 0 ; $i--) //skips TLD
{
if (preg_match($invalid, $urlHost_a[$i]))
{
echo 'failed on '.$urlhost_a[$i].'<br>';
}
else
{
echo 'valid domain name(s)<br>';
}
}

Any suggestions on how to construct that $invalid pattern? I'm not sure what
syntakx to use or what characters need to be escaped.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация