On Wed, Aug 04, 2004 at 02:24:09PM +1000, Jamie Wilkinson wrote:
> This one time, at band camp, Alexander Samad wrote:
> >Hi
> >
> >
> >a friend has to implement in regex  something along these lines of these
> >rules to match against a string (password)
> >
> >Must match 3 out of 4 rules
> >
> >1) Contain 1 or more Uppercase char
> >2) Contain 1 or more Lowercase char
> >3) Contain 1 or more numeric
> >4) Contain 1 or more punctuation 
> 
> Firstly, you can't count in a regex, so you can't say "once 3 of these
> match, then succeed."
looking for 1 regex statement and perlre is the standard I think, the
sort of thing I was thinking of but really ugly was (where [:1:] - set
of chars that meets rule 1 above)

 ([:1:]+[:2:]+[:3:]+|[:1:]+[:2:]+[:4:]+|...) rather long and painful

> 
> So really you want to test for each of these (with or without a regex) and
> then sum the results.
> 
> You didn't say what language, so man perlre for some common regex syntax,
> and the re module from http://www.python.org/doc/lib/ for some python
> documentation.
> 
> I can think of a python solution with about 6 lines in it, but I'd hate to
> deprive you of the joy of learning.  Have fun!
> 
> -- 
> [EMAIL PROTECTED]                           http://spacepants.org/jaq.gpg
> -- 
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
> 

Attachment: signature.asc
Description: Digital signature

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to