規(guī)則如下<div class='ad'><div>dfdferhgthghg</div><div>tgtgfbvf</div><div>rtrggf</div>...................div個(gè)數(shù)不定</div>匹配從<div class='ad'>到</div>的所有字符串,中間的div 必須是嵌套出現(xiàn)
2 回答

慕姐8265434
TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊
string beginstr="<div class='ad'>";
string endstr="</div>";
Regex rg = new Regex(string.Format(@"{0}(?<g1>.*){1}", beginstr, endstr));
if (rg.IsMatch(input))
{
return rg.Match(input).Groups["g1"].Value;
}
- 2 回答
- 0 關(guān)注
- 676 瀏覽
添加回答
舉報(bào)
0/150
提交
取消