Re: Regexp help

Michael McCallum <[email protected]> Tue, 22 Apr 2003 09:10:41 +1200
Newsgroups gmane.comp.jakarta.regexp.user
Organization SnapHire Inc
Message-ID <[email protected]>
On Monday, 21 April, 2003 21:53, Mete Kural wrote:
> Hi,
> I'm using the Commons-Validator framework that uses Regexp for masking user
> input. I'm not familiar with regular expressions and I would like to learn
> some, but I have a short timeframe to learn them. What online sources would
> you recommend that briefly introduce one to regular expressions?
>
> Also, if you could give me regular expression examples for the below cases
> I would really appreciate it:
Its really not that hard to find help on the ==> 
nethttp://www.google.com/search?hl=en&lr=&ie=ISO-8859-1&q=simple+regular+expressions

>
> 1) XXXXX-XXXX where X is any digit. This is supposed to be a zip/postal
> code but the last 4 zip code digits are not required.
"[0-9]{5}-[0-9]{4}?" 
you might need some parentheses in here:
"[0-9]{5}-([0-9]{4})?" 
you might get away with this too depending if you have to four or no extra 
digits
"[0-9]{5}-[0-9]{0,4}"

>
> 2) YYYY...YYY where Y is alpha-numeric and does not include any punctuation
> marks. Basically I want validate user input for choosing a password that
> includes only certain set of characters.
"[:alpha:]+"
if you want a minimum number try this
"[:alpha:]{7,}"

>
> Thank you very much,
> Mete
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]

-- 
Michael McCallum
Software Engineer
SnapHire Inc.
ph: +649.308.0329
http://www.SnapHire.com/