I have an And/Or regex i.e (PatternA|PatternB) in which I only take PatternA if PatternB does not exist (PatternB always comes after PatternA but is more important) so I put a negative lookahead in the PatternA Pipe.
This works on shorter text blocks:
https://regex101.com/r/bU6cU6/5
But times out on longer text blocks:
https://regex101.com/r/bU6cU6/2
What I don't understand is if I put PatternA with the Neg Look ahead alone in the same long text block it takes only 32 steps to reject it:
https://regex101.com/r/bU6cU6/3
and if I put PatternB alone in the same long text block it only takes 18 steps to accept it:
https://regex101.com/r/bU6cU6/4
So I am not sure why it is taking 100,000+/timeout to first reject (32 steps) then accept (18 steps) with the pipes. Is there another/better way to construct so it checks PatternA first than PatternB because now it is doing something I don't understand to go from 50 steps to 100k +.