What is the correct way to match all the instances of [ ] in a string.
I'm trying with
String content = "ZZZ AA PP [AA] Q[QQ] AAA ZZ";
String string = "\\[.*\\]";
Pattern pattern = Pattern.compile(string);
Matcher matcher = pattern.matcher(content);
It matches from [AA] Q[QQ] as a single instance whereas I want to get both the instances between [].
Any help would be appreciated.