Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Struts2 Field Validator in XML - regex issue

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am using the xml validation for an action in my struts2 application. The issue I'm experiencing is related to a regex validator that I've listed below. Basically, I'm trying to prevent anyone from entering a caret (^) in my course name field.

The following inputs work with this regex:
^a
^asdfds
b^
D^dfda

However, if someone enters just a caret for the course name, the regex fails. It does not find the caret for some reason. I've test the following two regex with this same result, so I'm guessing it is struts2/java related rather than my regex.

regex 1: ([\^])
regex 2: \^

All other validation is working correctly, it's just this regex that is causing me problems. Anyone know what I'm doing wrong?

 
Michael Freake
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I just tried the following regex and it also fails, but it works when I try it using online validators as do the previously posted regex.

^.*([\^])+.*$
 
What are your superhero powers? Go ahead and try them on this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic