Re: Re: validate URL -> add it to QuickForm?

From: Date: Thu, 04 Dec 2003 17:54:55 +0000
Subject: Re: Re: validate URL -> add it to QuickForm?
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-24153@lists.php.net to get a copy of this message
hello, Thanks to all of you for being so responsive. perhaps the regex below could be added as q QuickForm rule. Although I must say it's probably better to accumulate stuff like this in Validate and in Validate only. I've read that adding PEAR::Validate rules to QuickForm is very possible so.. It's just that Validate is still marked as alpha... jeroen Frederic Poeydomenge wrote:
Hi,
Davey <davey@php.net> wrote : From the URI RFC, comes this amazing section: ...
      ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
       12            3  4          5       6  7        8 9
... I have yet to actually get this regex to work with ereg...
the following version is working with ereg : function ereg_parse_url($s) { if (ereg('^(([^:/?#]+):)?([/]{2}([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?',$s,$regs)) { return $regs; } else { return ''; } }
I think unless you need to *parse* the URI a lot of the parens could be removed... and moving it to PCRE instead of POSIX would be beneficial. This needs a regex guru for sure :D
and the following one is working with preg ;D function preg_parse_url($s) { if (preg_match('!^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?!',$s,$matches)) { return $matches; } else { return ''; } } you can notice that the only difference with the generic URI syntax as found in the RFC are just the ! at the start and the end of the regex... no need to be a regex guru ;-) Regards, -------------------- Frederic Poeydomenge


« previous php.pear.dev (#24153) next »