You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by Mete Kural <me...@mail.touchtonecorp.com> on 2003/04/21 11:53:37 UTC

Regexp help

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:

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.

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.

Thank you very much,
Mete

---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org


Re: Regexp help

Posted by Michael McCallum <mi...@snaphire.com>.
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: regexp-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: regexp-user-help@jakarta.apache.org

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

---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-user-help@jakarta.apache.org