Re: Registerrule(), regular expression for checking url
| From: | Ignatius Reilly | Date: | Thu, 15 Apr 2004 10:55:28 +0000 |
| Subject: | Re: Registerrule(), regular expression for checking url | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11854@lists.php.net to get a copy of this message | ||
This is not a QF, but a REGEX mistake
"/" is the regex boundary delimiter.
either choose another delimiter or escape instances of "/" inside the regex.
Ignatius
_________________________
"Tommy Ipsen" <tipsen@imada.sdu.dk> wrote in message
news:20040415103246.35755.qmail@pb1.pair.com...
> Hi
>
> As far as I remember I've formerly used this line
>
> $form->registerRule('url', 'regex',
>
'/^(file|ldap|http|https|ftp)://(([-a-z0-9])+\.)+([a-z]{2,6}|([a-z/]+[a-z/]{
2,6}))$/');
>
> to add a rule verifying if a form field contains a valid url - apparently
the '/' is making problems
> now since I'm getting the following error:
>
> Warning: Unknown modifier '/' in
Z:\www_test\cmjern\pear\HTML\QuickForm\Rule\Regex.php on line 57
>
> Can anyone fix the above regular expression or perhaps come up with a
better one?
>
> I know that it's allowing many invalid url's but it's just meant as a
crude check to help the user.
> This means I will rather accept an invalid url than reject a valid one!
>
> Hope you can help!
>
> Cheers,
>
> Tommy Ipsen