In java im trying to use a regex to match some stacktrace lines.
I just want to keep the lines that are usefull for me: lines that does not start with tab or space, and lines that contain some.package in it. The following regex work matching the whole line 1 and 3 in all the online regex tools I tested so far:
.*?at some.nested.package.*$|^[^ ].*$
My stackTrace data is:
java.lang.NullPointerException: text
at java.base/java.time.LocalDate.parse(LocalDate.java:415)
at some.nested.package.controllers.someMethod(SomeFile.java:122)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Why this regex is not working? boolean match is never true.
Sample code:
String[] arrayStackTrace = stackTrace.split("n");
for(String lineStackTrace : arrayStackTrace) {
boolean match = pattern.matcher(lineStackTrace).matches();
}
Thanks, Nestor.