正则表达式:如何匹配不以前缀列表开头的子字符串

Regex: How to match substrings not starting with a list of prefixes

我需要替换字符串中的匹配词,但不包括这些词的前缀列表。

The matchingWord should be replaced in the first line
But excludePrefix1.matchingWord , not in this line
Neither in this other line excludePrefix2.matchingWord
But again in this allowedPrefix.matchingWord

我用一个前缀的正则表达式成功了:

(?<!(excludePrefix1\.))matchingWord

但是我如何使用几个排除的前缀来做到这一点?

我试过类似的东西:

(?<!((excludePrefix1\.)(excludePrefix2\.)))matchingWord

但这不起作用,请正则表达式专家可以帮助我们解决这个棘手的问题吗?

在一些工具中,负后向必须是固定长度,对于你的问题,使用多个后向:

(?<!excludePrefix1\.)(?<!excludePrefix2\.)matchingWord