Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy/Java split string on parentheses "("

I am trying to perform a split similar the following:

println "Hello World(1)".split("W"); 

Output:

[Hello , orld(1)] 

I want to perform this split:

println "Hello World(1)".split("("); 

But I see:

Caught: java.util.regex.PatternSyntaxException: Unclosed group near index 1 ( 

Is there a way I can escape this parentheses? Any help is appreciated.

like image 571
Kyle Weller Avatar asked Mar 05 '13 23:03

Kyle Weller


1 Answers

println "Hello World(1)".split("\\("); 
like image 164
Memento Mori Avatar answered Sep 20 '22 15:09

Memento Mori