I want to extract all the substrings that have Exceptions. For example, "SQLException", "SQLSyntaxErrorException" etc from the below string, and store those values in a String array. How do I go about it? I tried to use the split(regex) method but that stores everything else in the array but not those exceptions. Help is appreciated.
public static void exceptionsOutOfString(){
String input = "org.hibernate.exception.SQLException: error executing work org.hibernate.exception.SQLGrammarException: error \n" +
"executing work at ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final] \n" +
"\\norg.hibernate.exception.SQLGrammarException: error executing work at ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final] \n" +
" Caused by: java.sql.SQLSyntaxErrorException: malformed string: 'Acme'' at";
String regex = ".[a-zA-Z]*Exception";
String[] exceptions = input.split(regex);