Which ones are more effective or (if equivalent) that are better readable? I am trying to match everything inside a pair of parentheses.
Pattern p1 = Pattern.compile("\\([^)]*\\)"); Pattern p2 = Pattern.compile("\\(.*?\\)");
For me, the second one is better read, but it uses a possible confusing quantifier of uncertainty, and I'm not sure if this leads to a loss of performance.
EDIT
Do not miss the answer, which shows that it is even better:
Pattern p3 = Pattern.compile("\\([^)]*+\\)");
source share