Reputation: 1253
I was developed one application using grails 1.3.7 version. where i was using regex expression for password validation.
like..
public static final String MYFAX_PASSWORD_REGEX_PATTERN = "[a-zA-Z0-9!@#\$%^&*()<>{};:.\\]\\[]{4,20}"
and it's working fine but when i am upgrading this project into grails 2.x then its' display me below compilation error.
Can anybody help me?
illegal escape character
public static final java.lang.String MYFAX_PASSWORD_REGEX_PATTERN = "[a-zA-Z0-9!@#$%^&*()<>{};:.\]\[]{4,20}";
Upvotes: 0
Views: 419
Reputation: 6216
You can try the Groovy ~"pattern"
expression:
def MYFAX_PASSWORD_REGEX_PATTERN = ~/[a-zA-Z0-9!@#$%^&*()<>{};:.\]\[]{4,20}/
For more information refer to the Groovy Regular Expressions manual.
Upvotes: 1
Reputation: 7966
The $ is used to put expressions inside a GString.
So you should escape it \$
Upvotes: 1