On Oct 22, 2:18 pm, [EMAIL PROTECTED] (Jay Savage) wrote:
> On 10/22/07, Paul Lalli <[EMAIL PROTECTED]> wrote:
>
> > On Oct 22, 2:45 am, [EMAIL PROTECTED] (Michael Alipio) wrote:
>
> > > The output should be a dictionary file that is minimum
> > > 6 characters and maximum 15 characters with at least 4
> > > letters and 2 numbers in it.. no special characters
> > > whatsoever.. This should be a simple regex but it's
> > > been a while since i wrote my last regexp program.
> > > Need to refresh my perl basics a little bit..
>
> > Don't fall into the trap of trying to express every one of your
> > requirements as one giant regexp.  There's no reason for that.
>
> That said, why prefer
>
>     next unless /^[[:alnum:]]{6,15}$/;
>
> to, say
>
>     next unless length() >= 6 && length() <=15;

Because the latter requires two calls to length(), and still doesn't
insure that all the characters are alpha numerics.  Which means you
will still need an additonal test of

next unless/^[[:alnum:]]+$/;

If you have to do that test anyway, it seems a lot simpler to change
the + to a {6,15} rather than writing out another two tests.

Paul Lalli


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to