import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "\\[.*?\\)";
final String string = "Steps:\\n\\n[Step as , asdasd . sd32 'd](http://dev.nzfood-site.wn.bauer-media.net.au/silver-fern-farms-competition-21001) 1 Preheat oven to 120°C. Arrange six 1 1/2-cup ramekins in large baking dish lined [with](http://dev.nzfood-site.wn.bauer-media.net.au/silver-fern-farms-competition-21001) a cloth. \\nStep 2 In a medium saucepan, combine cream and vanilla. Place over medium heat and bring to almost boiling point. \\nStep 3 Meanwhile, in a bowl, whisk yolks and sugar together until thick and pale. Gradually pour in hot cream mixture, whisking constantly. \\nStep 4 Return mixture to clean saucepan. Cook on low heat 10-12 minutes, stirring constantly until thick enough to just coat the back of a wooden spoon (be careful not to overheat or mixture will curdle). \\nStep 5 Divide custard between ramekins. Pour boiling water into baking dish to come halfway up sides of ramekins. Bake 20-25 minutes until almost set and slightly wobbly in centre. Remove ramekins. \\nStep 6 Cool completely in fridge. Just before serving, sprinkle custards with an even layer of raw sugar. Using a kitchen blowtorch, drag the flame back and forth over the sugar until caramelised.";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(string);
while (matcher.find()) {
System.out.println("Full match: " + matcher.group(0));
for (int i = 1; i <= matcher.groupCount(); i++) {
System.out.println("Group " + i + ": " + matcher.group(i));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html