Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

regular expression for mask in validation.xml

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
Can anybody please tell me how do we use a regular expression to validate when a field starts with any of the given strings say "abc","xyz","ghi"
i have tried this in validation.xml
<var-name>mask</var-name>
<var-value>^[^(abc)|(xyz)|(ghi)]]</var-value>
but this did not work
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure about how to use it in Struts, but this regexp seems better:

^(abc|xyz|ghi)

As an aside, "this did not work" is a rather deficient description of a problem. How did it not work - was the validation used, but the regexp didn't capture what you thought it would capture? Or was the validation never used? Or something else?
[ February 22, 2006: Message edited by: Ulf Dittmer ]
 
Shilpa Asuthkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Ulf Dittmer ,

with did not work i meant that the validation did not work as expected i mean its checking for string that starts with any of the letters or combination of letters in the list ie a b c x y z g h i seperately,sorry for not making it clear earlier. i have tried with the regular expression which u have suggested but this doesnot work as expected as well
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

this does not work as expected as well


Please, read this before your next post.

Both this and this regexp tester indicate that the regexp I gave matches "abc...", but not "a...", and it uses only standard regexp features.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic