aspose file tools*
The moose likes Struts and the fly likes regular expression for mask in validation.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "regular expression for mask in validation.xml" Watch "regular expression for mask in validation.xml" New topic
Author

regular expression for mask in validation.xml

Shilpa Asuthkar
Greenhorn

Joined: Dec 22, 2005
Posts: 10
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
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
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 ]

Ping & DNS - my free Android networking tools app
Shilpa Asuthkar
Greenhorn

Joined: Dec 22, 2005
Posts: 10
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
Marshal

Joined: Mar 22, 2005
Posts: 42276
    
  64
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regular expression for mask in validation.xml