views:

228

answers:

1

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.

+3  A: 

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());
Bart Kiers
the problem is my client does not want to write "\(" in the note field which is a textArea field. People like to write 1). something; 2). good stuff; 3) ok.......how could I let my client write frieely without crashing my program?thanks!!!!!!
john
@user311884, see the edit.
Bart Kiers