正則表達式可以用行號獲取雙引號和單引號內的文本。正則表達式只能得到雙引號和單引號內的文本以及行號
例如:
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( 「\」」, 「」)。替換( 「」「, 」「)'來刪除引號? – jgok222 2013-05-10 13:13:04