2

这是我在 C# 中的正则表达式:

(?<!\([\w\s]+)\bSWORD\b

我现在在 JavaScript 中需要这个。我是正则表达式的新手,所以我不知道如果没有后视我将如何做到这一点。任何帮助,将不胜感激。

4

1 回答 1

3

Since you don't have a lookahead as well, there is a neat trick. Reverse the input string and apply the reversed regular expression:

\bDROWS\b(?![\w\s]+\()

If you want the position of the match in the actual input string, then you can find it as:

lengthOfInputString - (foundMatchPosition + lengthOfMatch)
于 2012-12-06T15:28:09.010 回答