fix edge case regex parsing performance on v8