• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Struts validation regular expressions

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was trying to use validations using Regular expressions. The first expression should only allow text in the value 01 - 07. The value must contain the '0' at the beginning. This expression works fine. The second expression should only allow text in the range 001 - 999. However the expression I have written allows 000 - 999. Do you know how I can not allow the value 000 but allow the rest of the expression? Using Struts 1.1.

Thanks in advance
Clinton

First Expression
<field property="rate" depends="required,mask">
<arg0 key="label.offermgmt.rate" />
<var>
<var-name>mask</var-name>
<var-value>^[0]{1}[1-7]{1}$</var-value>
</var>
</field>

Second Expression
<field property="optionSet" depends="required,mask">
<arg0 key="label.offermgmt.option" />
<var>
<var-name>mask</var-name>
<var-value>^[0-9]{1}[0-9]{1}[0-9]{1}$</var-value>
</var>
</field>
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I havent tested this with Struts validator, but have you tried something like this:

^(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9])$

There are probably other ways to do this also using numerics
 
So there I was, trapped in the jungle. And at the last minute, I was saved by this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic