In this Java code:
public class Main {
public static void main(String[] args) {
"".matches("(?<!((.{0,1}){0,1}))");
}
}
the compiler (I'm using JVM 1.6.0_17-b04) shouts "Exception ... Look-behind group does not have an obvious maximum length". I saw here that:
Java takes things a step further by allowing finite repetition. You still cannot use the star or plus, but you can use the question mark and the curly braces with the max parameter specified. Java recognizes the fact that finite repetition can be rewritten as an alternation of strings with different, but fixed lengths.
But... in the code above there is very obvious finite maximum length - 1 (simple product).
The real problem is, of course, in more complex patterns, like:
(?<!bad(\s{1,99}(\S{1,99}\s{1,99}){0,6}))good
(good word, that has no bad word behind, in 7-words-range).
How can I fix it?