如何当我试图让之间的所有子[&QUOT解决这个错误;和",(有代码)? [英] How to fix this error when I try to get all substring between [" and ", (have code)?

查看:172
本文介绍了如何当我试图让之间的所有子[&QUOT解决这个错误;和",(有代码)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有字符串:

new y",[["new york",0,[]],["new york times",0,[]

我想这些字符串betwent [

I want these string betwent [" and ",:

new york
new york times

我尝试这个功能:

public MatchCollection s;
...
s =  Regex.Matches(s44, "[\".*?\",");

但我得到这个错误: ArgumentException的是未处理:prasing [,*。? - ?!未终止的[]集

您可以帮我解决这个问题,非常感谢您

Can you help me solve this problem? Thank you very much!

编辑:我要不要字符串有 [

The string I want dont have [" and ",

推荐答案

您需要逃跑的支架上。此外,需要引进一批通过使用括号你想要的文字比该组中包含的:

You need to escape the bracket. Additionally, you need to introduce a group by using the parenthesis. The text you want is than contained in that group:

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

这篇关于如何当我试图让之间的所有子[&QUOT解决这个错误;和",(有代码)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆