struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rod Bollinger" <techi...@portablegenius.com>
Subject RE: Help in using regex in Validation.xml
Date Wed, 01 Aug 2007 14:33:22 GMT
This won't actually work. The parentheses should be braces and if you don't
supply the start ("^") and end ("$") delimiters you will match nine-digit
patterns within larger patterns as well (which I assume you don't want).

The correct simple syntax is: ^000\d{6}$

In your code, if you DON'T get a match, you have a valid nine-digit number
(i.e. a number that is nine digits in length and DOES NOT start with "000").

If you DO match, you have an invalid item.

HTH,
-Rod

-----Original Message-----
From: Jasper Floor [mailto:jasperfloor@gmail.com] 
Sent: Wednesday, August 01, 2007 06:17
To: Struts Users Mailing List
Subject: Re: Help in using regex in Validation.xml

On 8/1/07, sriharsha.chevuru@wachovia.com
<sriharsha.chevuru@wachovia.com> wrote:
> Hi,
>
> This question can be termed as an OT as it is related to regex. I have a
> validation criteria which says:
>
> a number cannot start with "000" which is 9 digits in length.
>
> Can somebody help me in writing a regular expression for this?

What exactly are the criteria?
If its only a nine digit number that cannot start with 000 then I
would look for a number which does start with 000

000\d(6)

if it matches you know it's wrong.

If the number of digits are variable, or you want to catch 00, 100
011, then it gets a little more difficult.

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




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


Mime
View raw message