Unfortunately, Java's builtin regex support has problems with regexes containing repetitive alternative paths (that is, (A|B)*
). This is compiled into a recursive call, which results in a StackOverflow error when used on a very large string.
A possible solution is to rewrite your regex to not use a repititive alternative, but if your goal is to tokenize a string on semicolons, you don't need a complex regex at all really, just use String.split() with a simple ";"
as the argument.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…