【发布时间】:2025-12-15 07:10:02
【问题描述】:
我需要替换字符串中匹配的单词,但不包括这些单词的前缀列表。
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
但这不起作用,请一位正则表达式专家帮助我们解决这个棘手的问题?
【问题讨论】: