groovy: how to escape "(" regex etc in textarea?
I 开发者_高级运维have some text area field in my grails application. I got the following errors:
.PatternSyntaxException: Unmatched closing ')' near index 36 Name: note: 1) data listing ....
how could i escape the regular expressions in the text area field?
thanks.
The same as in a literal: place a backslash before it:
\(
EDIT: But if none of the characters from the text area must be treated special, try:
String escapedContents = java.util.regex.Pattern.quote(textArea.getText());
精彩评论