C# 在c语言中修剪多行字符串#
我有一根像C# 在c语言中修剪多行字符串#,c#,asp.net,html-agility-pack,C#,Asp.net,Html Agility Pack,我有一根像 address 424 G UT <br> 这仅对齐第一行,而不是第二行。 同时也会以html格式打印。如何使用html agility pack删除html标记和空格。使用此选项修改您的c代码 这里是html <div id="node5" runat="server"> address 424 G UT
address
424 G UT <br>
这仅对齐第一行,而不是第二行。
同时也会以html格式打印。如何使用html agility pack删除html标记和空格。使用此选项修改您的c代码 这里是html
<div id="node5" runat="server">
address
424 G UT <br>
</div>
<div>
<asp:Button ID="btmGetDivdetails" runat="server" Text="getDivdetails"
onclick="btmGetDivdetails_Click" />
</div>
地址
424克UT
点击按钮上的c#代码
protected void btmGetDivdetails_Click(object sender, EventArgs e)
{
string trimstr = node5.InnerHtml;
trimstr = trimstr.Replace("\r\n<br>", "").Replace("\r", "").Replace("\n", "").Trim();
if (trimstr.Contains("<br>"))
{
trimstr = trimstr.Replace("<br>", "");
}
List<char> result = trimstr.ToList();
result.RemoveAll(c => c == ' ');
string finalresult = new string(result.ToArray());
}
protectedvoid btmGetDivdetails\u单击(对象发送方,事件参数e)
{
字符串trimstr=node5.InnerHtml;
trimstr=trimstr.Replace(“\r\n
”,”).Replace(“\r”,”).Replace(“\r”,”).Replace(“\n”,”).Trim();
if(trimstr.Contains(“
”)
{
trimstr=trimstr.Replace(“
”,”);
}
列表结果=trimstr.ToList();
result.RemoveAll(c=>c='');
string finalresult=新字符串(result.ToArray());
}
现在最后的结果是“address424GUT”嘿,guyz,我在c中使用了trim函数,我得到的文本是这样的随机格式(很多空格和换行符)。
protected void btmGetDivdetails_Click(object sender, EventArgs e)
{
string trimstr = node5.InnerHtml;
trimstr = trimstr.Replace("\r\n<br>", "").Replace("\r", "").Replace("\n", "").Trim();
if (trimstr.Contains("<br>"))
{
trimstr = trimstr.Replace("<br>", "");
}
List<char> result = trimstr.ToList();
result.RemoveAll(c => c == ' ');
string finalresult = new string(result.ToArray());
}