-
problem with zero value validation using format mask (regexp) (1 messages)
- Posted by: Ramalingeswara Rao K V
- Posted on: March 27 2008 05:03 EDT
I have to restrict zero numeric value and non-numeric values using format mask. I have done the following example. It is restricting Non-Numeric and "0" values. But, it is not restricting "00" and "000" values. Code: - ==== Pattern pat = Pattern.compile("[1-9]|([0-9]{2,3})"); Matcher matcher = pat.matcher("00"); boolean flag = matcher.matches(); System.out.println(flag);Threaded Messages (1)
- Re: problem with zero value validation using format mask (regexp) by Andy Leung on March 28 2008 08:50 EDT
-
Re: problem with zero value validation using format mask (regexp)[ Go to top ]
- Posted by: Andy Leung
- Posted on: March 28 2008 08:50 EDT
- in response to Ramalingeswara Rao K V
I have to restrict zero numeric value and non-numeric values using format mask.
I am not sure if I understand your question but your regular expression looks like it is accepting 00 or 000 to me and if this is the case, the following is what I think you may look for: Pattern pat = Pattern.compile("[1-9]|([1-9]{2,3})"); Matcher matcher = pat.matcher("00"); boolean flag = matcher.matches(); System.out.println(flag);
I have done the following example.
It is restricting Non-Numeric and "0" values.
But, it is not restricting "00" and "000" values.
Code: -
====
Pattern pat = Pattern.compile("[1-9]|([0-9]{2,3})");
Matcher matcher = pat.matcher("00");
boolean flag = matcher.matches();
System.out.println(flag);