java - Decode Regex expression - ^[a-zA-Z0-9 "'&!#$%()*+,-./:;?@[\\]^_`{|}~]+$ -
java - Decode Regex expression - ^[a-zA-Z0-9 "'&!#$%()*+,-./:;?@[\\]^_`{|}~]+$ -
using java
i not regular on regex, came across next regex part of migration of springmodules-validation stuff latest.
^[a-za-z0-9 "'&!#$%()*+,-./:;?@[\\]^_`{|}~]+$
what doing? need understand write unit test validation. way i'm using in java project.
one more interesting thing, tried look in hibernate-validator
follows:
@pattern(regexp = "^[a-za-z0-9 "'&!#$%()*+,-./:;?@[\\]^_`{|}~]+$")
then intellijidea shows error @ end of line saying unclosed character class. regex look formed?
update
it seems look malformed, see next exception while trying test this:
java.util.regex.patternsyntaxexception: unclosed character class near index 57 ^[a-za-z0-9 "'&!#$%()*+,-./:;?@[\]^_`{|}~]+$
here original look 1 of xml files i'm trying migrate:
<regexp apply-if="creativetype == 'text'" expression="^[a-za-z0-9 "'&!#$%()*+,-./:;?@[\\]^_`{|}~]+$"/>
am missing anything?
working solution
regexp = "^[a-za-z0-9 \"'&!#$%()*+,-./:;?@\\[\\]^_`{|}~]+$"
this way have assigned string , works me give thanks all!
the translated look like
^[a-za-z0-9 "'&!#$%()*+,-./:;?@\[\]^_`{|}~]+$
and means line of letter, digits , set of other characters (like different brackets, ] has escaped not meaning end of character class).
java regex hibernate-validator spring-modules
Comments
Post a Comment