I am trying to get all the columns selected within a SQL query (including the sub selects). When the code hits matcher.find(). i get the following exception:
Exception in thread "main" java.lang.Stack OverflowError
at java.util.regex .Pattern$Branch .match(Pattern. java:4530)
at java.util.regex .Pattern$GroupH ead.match(Patte rn.java:4570)
I am not sure where in the regex is causing the inifinite loop.
Can anyone shed light on this?
String regex = "^select(([^\\(]|\\([^\\(]+\\))*)from";
Pattern pattern = Pattern.compile (regex, Pattern.CASE_IN SENSITIVE | Pattern.DOTALL | Pattern.MULTILI NE);
Matcher matcher = pattern.matcher (sql);
if (matcher.find() ) {
// Get all groups for this match
for (int i = 0; i <= matcher.groupCo unt(); i++) {
String groupStr = matcher.group(i );
}
}
Exception in thread "main" java.lang.Stack OverflowError
at java.util.regex .Pattern$Branch .match(Pattern. java:4530)
at java.util.regex .Pattern$GroupH ead.match(Patte rn.java:4570)
I am not sure where in the regex is causing the inifinite loop.
Can anyone shed light on this?
String regex = "^select(([^\\(]|\\([^\\(]+\\))*)from";
Pattern pattern = Pattern.compile (regex, Pattern.CASE_IN SENSITIVE | Pattern.DOTALL | Pattern.MULTILI NE);
Matcher matcher = pattern.matcher (sql);
if (matcher.find() ) {
// Get all groups for this match
for (int i = 0; i <= matcher.groupCo unt(); i++) {
String groupStr = matcher.group(i );
}
}