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 &quot;&apos;&amp;!#$%()*+,-./:;?@[\\]^_`{|}~]+$"/>

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

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -