I am implementing a regular expression engine and have encountered an interesting gotcha; If you attempt to match the expression /(?>a)*/
against "a"
you theoretically have an infinite number of positive zero width lookahead matches at index 0.
My question is: is even reasonable to match quantified zero width matches? Should I let this run infinitely and blame the person who wrote the expression or should I catch and deny this type of match?
Edit: Or maybe just one single match and ignore the fact that it asked for more?
Edit 2: Currently, my engine sees the zero width match, adds it to the result (zero characters), stays at the same index, and finally goes back to the same zero width expression as many times as possible (which is unbounded when used with *, +, {n,}, etc).