I have a String containing natural numbers and between of them any pattern like (,-) or (,). With a while - condition i make sure that the given Strings contains as less numbers as a given window size, e.g. 5.
The condition looks like that:
while(discretizedTs.substring(lagWindowStart).matches("(-?,?\\d+,){5,}")) {
}
Where lagWindowStart jumps to the index of the next number or (-,) pattern. For small Strings this regular expression is working fine (as far as tested). My Problem is, that for large Strings (and i have to deal with very large Strings normaly) this regular expression caused an SOF. This happens for example if the String contains more than 17k characters.
Is there a limitation of the length of a String which is to match? or a limit in time the matching must be completed? I did not know how to solve the given problem without regular expressions. I hope you have any ideas..
Thank you best
[^-,\d]+since your regex has nothing to do with the rest of the characters.while (temp_lag.matches("(-?,?\\d+,){"+lag_leadWindowSize+"}")==false){ do smthg;}but this would also match words with less numbers then the windowsize.. Sorry.. forgotten to say that the outer loop have to check if the String contains two times the windowsize many numbers. if the windowsize is 5 the outer loop have 10 as minimum. therefore i need two loops... it is hard to explain..