我正在使用以下常規(guī)表達(dá)式從字符串中刪除html標(biāo)簽。它有效,除了我留下了結(jié)束標(biāo)簽。如果我嘗試刪除:<a href="blah">blah</a>它將離開<a/>。我根本不了解正則表達(dá)式語法,并且對(duì)此一無所知。可以讓擁有RegEx知識(shí)的人給我提供一個(gè)可行的模式。這是我的代碼: string sPattern = @"<\/?!?(img|a)[^>]*>"; Regex rgx = new Regex(sPattern); Match m = rgx.Match(sSummary); string sResult = ""; if (m.Success) sResult = rgx.Replace(sSummary, "", 1);我希望刪除<a>and <img>標(biāo)簽的第一次出現(xiàn)。
- 3 回答
- 0 關(guān)注
- 650 瀏覽
添加回答
舉報(bào)
0/150
提交
取消