perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gerald Richter" <rich...@ecos.de>
Subject RE: Form Validation
Date Thu, 23 Jun 2005 03:54:34 GMT
> 
> Gerald, is it possible this is a bug:
> 
> I notice that your validation for the Number type uses this regex:
> 
> /^\s*[0-9+-.][0-9.eE]*\s*$/
> 
> However, that fails on a value such as 9.516e-5, which is a 
> valid float.
> 
> I believe you need to add a negative sign to the second 
> character class:
> 
> /^\s*[0-9+-.][0-9.eE-]*\s*$/
> 

Yes, you are right

> This regex is still a little too lax, because it will allow 
> malformed numbers like 
> 
> 9.5e5e-3 
> 
> through. 
> 

Yes, thats correct, patches are welcome :-)


> 
> --------
> 
> Also, I am successfully using the following rule:
> 
> $rules = [
>     [
>         -key    => 'user_seq',
>         -name   => 'User-inputted sequence',
>         emptyok     => 1,
>         -msg => 'blah blah blah',
>         matches_regex       => "^\\s*(>.+\\n)?[\\s$NT]+\$",
>     ]
> ];
> 
> Note that it's 'matches_regex', not 'matches_regex_js'. In 
> the docs it says that this shouldn't work on the client side, 
> but it does.
> 
> What is the difference between perl regular expressions and 
> javascript ones?
> 

Perl Regex are much more powerfull, so if you use "simple" pattern it will
work within both, some more complex things are only working in Perl. In such
cases you can use different regexes by using matches_regex_perl and
matches_regex_js .


> 
> p.s. The SetupSession/GetSession stuff is working great -- I 
> will have more to say on that in a bit. 
> 

Great!

Gerald


---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message