C Method for Deleting Text in Specified Label in UL LI
- 2021-12-21 04:40:22
- OfStack
This article illustrates how C # deletes the text in the specified label in UL LI. Share it for your reference, as follows:
Now demand more and more abnormal, but do code can only try to meet, here first deduct ul and li hyperlinks in the text
PromptHtml = GetData.GetHTTPInfo(Config.Prompt_Url, "utf-8");
PromptHtml = PromptHtml.Replace("<ul><li>", "");
PromptHtml=PromptHtml.Replace("</li></ul>", "");
string ss = @"<a[\s\S]*?href=""([^" rel="external nofollow" "]*?)""[^>]*?>([\s\S]*?)</a>"; // Here
MatchCollection mcTable = Regex.Matches(PromptHtml, ss);
foreach (Match mTable in mcTable)
{
if (mTable.Success)
{
PromptHtml = mTable.Groups[2].Value;
}
}
resultHtml = PromptHtml;
The specific data sources are as follows:
<ul><li><a href="http://localhost/tg.aspx?ID=4194" rel="external nofollow" > Which theme funds are expected to explode? </a></li></ul>
This article is to deduct the text in span in ul and li:
middlebannerHtml = GetData.GetHTTPInfo(Config.Middlebanner_Url, "utf-8");
middlebannerHtml = middlebannerHtml.Replace("<ul><li>", "");
middlebannerHtml = middlebannerHtml.Replace("</li></ul>", "");
string ss = @"<span>([^<]+)</span>"; // Here
MatchCollection mcTable = Regex.Matches(middlebannerHtml, ss);
foreach (Match mTable in mcTable)
{
if (mTable.Success)
{
middlebannerHtml = mTable.Groups[1].Value;
}
}
middleContent = middlebannerHtml;
The specific data sources are as follows:
<ul><li><span>3 Year 5 Double increase It's not just stocks ~</span> <a href="http://localhost/tg.aspx?ID=4195" rel="external nofollow" > View now </a></li></ul>
PS: Here are two very convenient regular expression tools for your reference:
JavaScript Regular Expression Online Test Tool:
http://tools.ofstack.com/regex/javascript
Regular expression online generation tool:
http://tools.ofstack.com/regex/create_reg
For more readers interested in C # related content, please check the topics on this site: "C # Regular Expression Usage Summary", "C # Coding Operation Skills Summary", "XML File Operation Skills Summary in C #", "C # Common Control Usage Tutorial", "WinForm Control Usage Summary", "C # Data Structure and Algorithm Tutorial", "C # Object-Oriented Programming Introduction Tutorial" and "C # Programming Thread Use Skills Summary"
I hope this article is helpful to everyone's C # programming.