I have this regexp
Pattern pattern = Pattern.compile("\\{([^\\}]+)\\}");
to match {a1|a2|a3} and {a4} format
How can I rewrite the above line, to include those matches only when a pipe | is present, so to match {a1|a2|a3} and do not match on {a4}