111,092
社区成员




string s = "...<tr>...12345...56789...54321...</tr>...";
Regex reg = new Regex(@"(?is)<tr>.*?</tr>");
Match m = reg.Match(s);
if(m.Success)
{
richTextBox2.Text = m.Value ;
}
/*-----输出------
<tr>...12345...56789...54321...</tr>
*/
(?is)<tr>.*?</tr>
(?isn)<tr>((?!</?tr\b).)*12345((?!</?tr\b).)*</tr>
string s = "...<tr>...98765...</tr>......<tr>...12345...</tr>...<tr>...54321...</tr>...";
Regex reg = new Regex(@"(?isn)<tr>((?!</?tr\b).)*12345((?!</?tr\b).)*</tr>");
MatchCollection mc = reg.Matches(s);
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}
/*-----输出------
<tr>...12345...</tr>
*/
string s = "...<tr>...98765...</tr>......<tr>...12345...</tr>...<tr>...54321...</tr>...";
Regex reg = new Regex(@"(?isn)<tr>((?!</?tr\b).)*</tr>");
MatchCollection mc = reg.Matches(s);
foreach (Match m in mc)
{
richTextBox2.Text += m.Value + "\n";
}
/*-----输出------
<tr>...98765...</tr>
<tr>...12345...</tr>
<tr>...54321...</tr>
*/