【发布时间】:2013-05-10 21:58:02
【问题描述】:
正则表达式获取带有行号的双引号和单引号内的文本。
例如:
line 123 Processing File "This is what i am looking for"<'this is also what i need'>
输出应该是:
line 123 This is what i am looking for this is also what i need
我的正则表达式是:
MatchCollection matches2 = Regex.Matches(l, "\"([^\"]*)\"");
foreach (Match match2 in matches2)
{
foreach (Capture capture2 in match2.Captures)
{
textBox4.Text = textBox4.Text + capture2.Value + Environment.NewLine;
}
}
我得到(我的输出):
"This is what i am looking for"
我不需要双引号,我只需要引号内的文字。
【问题讨论】:
-
不能用
string.replace("\"","").replace("'","")去掉引号吗?