Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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

Comment on Re: validate a form field with regexp?
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2015-11-28 07:21 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (739 votes), past polls