c#中的正则表达式否定前瞻

Mer*_*ith 3 c# regex visual-studio-2010 regex-negation

我需要匹配["this"但不是:["this"

我有这个代码:

        Match match = Regex.Match(result, @"\[""(.*?)""",
            RegexOptions.IgnoreCase);

        while (match.Success)
        {
            MessageBox.Show(match.Groups[1].Value.Trim());
        }
Run Code Online (Sandbox Code Playgroud)

我试过这个模式@"(?!:)\[""(.*?)""",但它仍然匹配:["this".我需要实现这个模式吗?

Aak*_*shM 5

当你想要向后看时(在字符串中向左),你正在向前看(在字符串中向右).

试试吧@"(?<!:)\[""(.*?)""".