I am just learning about using Regex and it does seem a bit complicated to me.
I am trying to parse this String in Java:
new Array(new Array('1','Hello'),new Array('2','World (New) Again'),new Array('3','Now'));
I want the output to end up as these matches:
'1','Hello'
'2','World (New) Again'
'3','Now'
I tried a few pattern, but the best I can get is that I get:
'1','Hello'
'2','World (New
) Again'
'3','Now'
This is my code:
Pattern pattern2 = Pattern.compile("([^\\(]*[']*['][^\\)]*[']*)");
s = "new Array(new Array('1','Hello'),new Array('2','World (New) Again'),new Array('3','Now'));";
Matcher matcher = pattern2.matcher(s);
while(matcher.find()){
String match = matcher.group(1);
System.out.println(match);
}