陣列我有一個像分割字符串從文本和HTML標記
string html = "truongpm<b><i>bold italic</i></b><b>bold</b><i>italic</i>";
字符串我如何獲得陣列狀
a[0] = "truongpm", a[1]= "<b><i>bold</i></b>", a[2]="<b>bold</b>", a[3]="<i>italic</i>"
從這個字符串。現在我用這個代碼
string tagRegex = @"<\s*([^ >]+)[^>]*>.*?<\s*/\s*\1\s*>";
MatchCollection matchesImgSrc = Regex.Matches(html, tagRegex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
foreach (Match m in matchesImgSrc)
,但它只是讓
a[0]= "<b><i>bold</i></b>", a[1]="<b>bold</b>", a[2]="<i>italic</i>"
沒有 「truongpm」 請幫幫我! 感謝
在當前模式之前放置'[^ <>] + |'。 – Jerry 2015-03-19 07:48:03