Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expression for ")

Status
Not open for further replies.

25884

Programmer
Mar 12, 2001
46
0
0
AP
Hi,

I want to get a correct regular expression for the string ")

Here is how I am doing it
String regex1 = "\"\)";
matcher = matcher.usePattern(Pattern.compile(regex1,Pattern.CASE_INSENSITIVE));

But i get this runtime error :

Exception in thread "main" java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 0
")
^

Thanks


 
Hi,

Sorry the error is


Abc.java:225: illegal escape character
String regex1 = "\"\)";
^
1 error
 
It then compiles fine but identifies the pattern specified as this : pattern="\)
 
I think you want :

Code:
String regex1 = "\"\\)";

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Humm, do you need to scape parenthesis for regex?

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top