From the string [foo](bar) I want to extract the foo and the bar part:
Pattern p = Pattern.compile("\\[(.*)\\]\\((.*)\\)");
String input = "[foo](bar)";
assert p.matcher(input).matches();
String[] a = ??? // should be initialized to {"foo", "bar"}
What do I write in the fourth line to obtain foo and bar from the input?
This should get you close to where you wanna be:
Essentially, you will create a
Matcher. Then usefind()to locate the match. Then you will use the groups to find the things that were matched inside of the parenthesis.