Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: validate a form field with regexp?

by Anonymous Monk
on Apr 21, 2012 at 07:06 UTC ( #966317=note: print w/replies, xml ) Need Help??

in reply to validate a form field with regexp?

See also Params::Validate, FormValidator::Simple, other validators


use Regexp::English; print Regexp::English ->new ->beginning_of_string ->literal('SR') ->digit ->digit ->digit ->digit ->digit ->digit ->digit ->end_of_string, "\n"; __END__ (?^:\ASR\d\d\d\d\d\d\d\Z)


use YAPE::Regex::Explain; print YAPE::Regex::Explain->new( qr{(?:\ASR\d\d\d\d\d\d\d\Z)} )->explain; __END__ The regular expression: (?-imsx:(?:\ASR\d\d\d\d\d\d\d\Z)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- \A the beginning of the string ---------------------------------------------------------------------- SR 'SR' ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \d digits (0-9) ---------------------------------------------------------------------- \Z before an optional \n, and the end of the string ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Replies are listed 'Best First'.
Re^2: validate a form field with regexp?
by chromatic (Archbishop) on Apr 21, 2012 at 08:00 UTC

      You're the first person I've seen use Regexp::English!

      I think it a nice crutch for newbies :) something I can copy/paste that newbies can run with

      FWIW, it needs patching, beginning is laborious to write, start man, start :)

        FWIW, it needs patching...

        I'll happily take patches or even give up some or all maintainership.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966317]
and a kettle whistles...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-09-23 10:04 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (272 votes). Check out past polls.