• Post Reply Bookmark Topic Watch Topic
  • New Topic

rplaceAll giving problem  RSS feed

 
Vaibhav Deshpande
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am trying to writing folowing code but getting error
"(javaranch)".replaceAll("(", "[").replaceAll(")", "]")
the above line get compiled but while running it gives following error
Exception in thread "main" java.util.regex.PatternSyntaxException: Unclosed grou
p near index 1
(
can some one reply quickly
thanks
vebs
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vaibhav,
Why not simply use String.replace?
The answer to your question, btw, is the ( is a meta-character in regex used for grouping, so it has to be delimited thus \(. The same is true for ).
M
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!