use of large input string causes the stack overflow, when the characters to be matched are added in alternation
input = "xyxyxyxy...";
regExpression = (x|y)*;
input.matches(regExpression);
Need to know what is the reason for the stack overflow in java? Found one related article that Java regular expression uses recursive calls to implement backtracking.
https://rules.sonarsource.com/java/tag/regex/RSPEC-5998
This gets resolved, when atomic group is created like
regExpression = (**?>**x|y)*
or
[xy]*
or
(x|y)*+