import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "failing[\\w\\W]*?\\d*\\)\\s[\\w\\W]*?\\:[\\s\\S]*?(Assert[\\w\\W]*?)[\\n].*(src[^:]+):(\\d+):(\\d+)";
final String string = " 1) validates input\n\n\n"
+ " 0 passing (660ms)\n"
+ " 1 failing\n\n"
+ " 1) statement:propose validates input:\n"
+ " AssertionError: expected { Object (status, err) } to have a deep property 'err' of 'err1', but got 'Error while fetching the changes from the event store: {}'\n"
+ " at doAsserterAsyncAndAddThen (node_modules/chai-as-promised/lib/chai-as-promised.js:307:16)\n"
+ " at .<anonymous> (node_modules/chai-as-promised/lib/chai-as-promised.js:255:21)\n"
+ " at ctx.(anonymous function) [as property] \n"
+ " at src/aggregate/index.js:144:100\n"
+ "(node_modules/chai/lib/chai/utils/overwriteMethod.js:49:33)\n"
+ " at Context.<anonymous> (src/aggregate/test/index.js:44:36)\n\n\n";
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