当我尝试获取["和"之间的所有子串,(有代码)时,如何修复此错误?

Tuy*_*ham -2 c# regex substring

我有字符串:

new y",[["new york",0,[]],["new york times",0,[]
Run Code Online (Sandbox Code Playgroud)

我想要这些字符串["",:

new york
new york times
Run Code Online (Sandbox Code Playgroud)

我试过这个功能:

public MatchCollection s;
...
s =  Regex.Matches(s44, "[\".*?\",");
Run Code Online (Sandbox Code Playgroud)

但我得到了这个错误:ArgumentException was unhandled: prasing "[".*?"," - Unterminated [] set.

你能帮我解决这个问题吗?非常感谢你!

编辑:我想串不具有["",

Dan*_*rth 6

你需要逃离支架.此外,您需要使用括号引入组.您想要的文本包含在该组中:

var matches = Regex.Matches(s44, "\\[\"(.*?)\",");
foreach(Match match in matches)
{
    var result = match.Groups[1].Value;
}
Run Code Online (Sandbox Code Playgroud)