Groovy: how to escape "(" regex, etc. in textarea?

I have a text area field in a grails application. I got the following errors:

.PatternSyntaxException: Unmatched closure ')' next to index 36 Name: note: 1) list of data ....

How can I avoid regular expressions in a text area field?

thank.

+3
source share
1 answer

Same as in a literal: put a backslash in front of it:

\(

EDIT: But if none of the characters from the text area are handled in a special way, try:

String escapedContents = java.util.regex.Pattern.quote(textArea.getText());
+10
source

Source: https://habr.com/ru/post/1740502/


All Articles