You are here: Re: OT URL REGEX « All PHP « IT news, forums, messages
Re: OT URL REGEX

Posted by Joseph Melnick on 09/28/66 11:17

Hello Alex,

How flexible does the regular expression have to be?

The regular expression you have in your example will match http or httpsor
ftp protocol servers that have IP addresses or names with extensions of 2 or
more characters.

There are a lot of references out there that can help yor correctly validate
urls.

For your url in question:

http://www.awin1.com/awclick.php?mid=xxx&id=xxxx

this is saying that you want the above url where there is a couple of
numbers of 1-4 digits that can change.

"^http\:\/\/www\.awin1\.com\/awclick\.php\?mid=[0-9]{1,4}&id=[0-9]{1,4}"

as in

<?php
$regex =
"^http\:\/\/www\.awin1\.com\/awclick\.php\?mid=[0-9]{1,}&id=[0-9]{1,}";
$url="http://www.awin1.com/awclick.php?mid=1&id=123";
if(eregi($regex,$url)){
echo "yes";
} else {
echo "no";
}
?>



"MS" <nospamplaesegr8t_ukuk@yahoo.co.uk> wrote in message
news:d7diq2$29c$1@nwrdmz02.dmz.ncs.ea.ibs-infra.bt.com...
>I know this is not really the place for this question but as I can not find
> a REGEX newsgroup I thought somebody here will have already solved this
> problem.
>
> I need a regex for validating urls.
>
> I got one off a website which is as follows...
>
> if(eregi("^(ht|f)tp(s?)\:\/\/[a-zA-Z0-9\-\._]+(\.[a-zA-Z0-9\-\._]+){2,}(\/?)
> ([a-zA-Z0-9\-\.\?\,\'\/\\\+&%\$#_]*)?$", $url)){
>
> but this does not allow dynamic urls the type you would get with affiliate
> programs...
>
> eg. http://www.awin1.com/awclick.php?mid=xxx&id=xxxx
>
> has anyone got a regex for URLs that would help me?
>
> Thanx in advance.
> Alex
>
> --
> ----------------------------------------------------------------------------
> http://www.clickonlingerie.com?SIG - Exotic Erotic Lingerie
> ----------------------------------------------------------------------------
>
>
>

 

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

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