C# 删除html标记,并在c中找到结束标记时将其拆分#
我想删除以下字符串中的所有html标记,并将其拆分,而不使用句点(句号)作为匹配字符。下面的sting是动态的,它可以在列表标记中包含更多条件C# 删除html标记,并在c中找到结束标记时将其拆分#,c#,windows-phone-8,C#,Windows Phone 8,我想删除以下字符串中的所有html标记,并将其拆分,而不使用句点(句号)作为匹配字符。下面的sting是动态的,它可以在列表标记中包含更多条件 <li>This Offer cannot be redeemed with any other offer.</li><li>Only one Offer can be used at a time.</li><li>This Offer is not transferable.</li
<li>This Offer cannot be redeemed with any other offer.</li><li>Only one Offer can be used at a time.</li><li>This Offer is not transferable.</li><li>......</li><li>....</li</ul></div>
此优惠不能与任何其他优惠一起兑换。 一次只能使用一个优惠。 此优惠不可转让。 ......字符串[]myString=yourString.replace(“,”).Split(新字符串[]{ “},StringSplitOptions.RemoveEmptyEntries);
试试这个
const string HTML_TAG_PATTERN = "<[^/li]>"; // may require some change
string safeString = Regex.Replace(yourString, HTML_TAG_PATTERN, string.Empty);
String[] myString = safeString.Split(new string[] { "</li>" }, StringSplitOptions.RemoveEmptyEntries);
const string HTML_TAG_PATTERN=“”;//可能需要一些改变
string safeString=Regex.Replace(yourString,HTML\u TAG\u模式,string.Empty);
String[]myString=safeString.Split(新字符串[]{“
”},StringSplitOptions.RemoveEmptyEntries);
你也可以试试这个正则表达式
string acceptable = "li";
string stringPattern = @"</?(?(?=" + acceptable + @")notag|[a-zA-Z0-9]+)(?:\s[a-zA-Z0-9\-]+=?(?:(["",']?).*?\1?)?)*\s*/?>";
string yourString= Regex.Replace(yourString, stringPattern, string.Empty);
String[] myString = yourString.replace("<li>", "").Split(new string[] { "</li>" }, StringSplitOptions.RemoveEmptyEntries);
string acceptable=“li”;
string stringPattern=@“如果您能够为您的
提供id,
您可以尝试使用如下javascript代码>>
var str=doccument.getElementById("liID").innerHTML;
您可以根据您的应用程序在windows onload事件或任何特定事件上尝试此功能。您可以删除所有html标记,并通过以下代码进行拆分
string HTML_TAG_PATTERN = "<.*?>";
string str = @"<li>This Offer cannot be redeemed with any other offer.</li><li>Only one Offer can be used at a time.</li><li>This Offer is not transferable.</li><li>......</li><li>....</li</ul></div>";
string[] stString = Regex.Replace(str.Replace("</li>", "#$#"), HTML_TAG_PATTERN, string.Empty).Split("#$#".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
string HTML_TAG_PATTERN=”“;
string str=@“此优惠不能与任何其他优惠一起兑换。 一次只能使用一个优惠。 此优惠不可转让。 … …首先向我们展示您所做的一切。我们在这里帮助您解决问题,而不是提供一些现成的解决方案,您只需复制粘贴并说eureka!我删除了html标记,但我希望它被拆分。返回Regex.Replace(inputString,“,string.Empty);请编辑您的问题并写下预期结果不要删除所有标签,构建一个正则表达式来删除所有标签,除了 他的q是什么,如果他用这个正则表达式删除了所有标签,那么他如何根据什么参数进行拆分?答案与windows phone不太相关
string HTML_TAG_PATTERN = "<.*?>";
string str = @"<li>This Offer cannot be redeemed with any other offer.</li><li>Only one Offer can be used at a time.</li><li>This Offer is not transferable.</li><li>......</li><li>....</li</ul></div>";
string[] stString = Regex.Replace(str.Replace("</li>", "#$#"), HTML_TAG_PATTERN, string.Empty).Split("#$#".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);