Re: OT URL REGEX
- From: "Joseph Melnick" <jmelnick@xxxxxxxx>
- Date: Mon, 30 May 2005 00:09:26 -0400
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@xxxxxxxxxxx> wrote in message
news:d7diq2$29c$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>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
> ----------------------------------------------------------------------------
>
>
>
.
- Follow-Ups:
- Re: OT URL REGEX
- From: MS
- Re: OT URL REGEX
- From: Joseph Melnick
- Re: OT URL REGEX
- Prev by Date: Re: interview questions for php developer
- Next by Date: Re: OT URL REGEX
- Previous by thread: How to change pictures everyday using php
- Next by thread: Re: OT URL REGEX
- Index(es):
Relevant Pages
|