[`(a?)(?:(?!a)[^])+\1`](https://redosdetector.com/?pattern=%28a%3F%29%28%3F%3A%28%3F%21a%29%5B%5E%5D%29%2B%5C1&unicode=false) is a false positive. [`(a?)[^a]+\1`](https://redosdetector.com/?pattern=%28a%3F%29%5B%5Ea%5D%2B%5C1&unicode=false) which is equivalent is properly detectes as ReDoS-free. If we tracked the lookahead along with what it was matching we could rule this out. See https://github.com/tjenkinson/redos-detector/issues/87#issuecomment-1133666041