Re: OT URL REGEX



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
> ----------------------------------------------------------------------------
>
>
>


.



Relevant Pages

  • Re: As I can determining if string can be turned to a numerico value?
    ... I tend to do most of my work in Perl, so regex and parsing is second nature, ... the scripts are small and the speed of execution is usually ... > Denis Dougall wrote: ... > check which is many times quicker than a regular expression. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Regular expressions
    ... if you are looking for Regular Expression help check out: ... RegEx Tutorial for VB: ... Sign the petition to Microsoft. ... >> newsgroups devoted exclusively to .NET programming. ...
    (microsoft.public.vb.syntax)
  • Re: Page.Invalid
    ... The regular expression validator compares the contents of your textbox against a regular expression (regex) If you haven't typed in the regular expression the validator is always going to return true. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Basic pattern matching - baffled
    ... $a is not used as a regex, it is treated as a literal string. ... The regular expression is on the right, what your testing is on the left: ... # numbers that can be matched in that single character position. ... the regular expression needs to escape '\' the escape character. ...
    (comp.lang.perl.misc)
  • RE: Cisco IPS 5.1
    ... Cisco IPS signature. ... URI Regex: Regular expression to search in the URI field. ... Regular expression to search in the HTTP arguments ...
    (Focus-IDS)