• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regular expression for mask in validation.xml

 
Shilpa Asuthkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • 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
  • 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: 42968
73
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic