VideoHome.Common/StrOperate.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
namespace Common
{
/// <summary>
/// 字符串操作类
/// </summary>
public static class StrOperate
{
/// <summary>
/// 按字节截断字符串。
/// </summary>
public static string GetSubString(string mText, int byteCount)
{
if (byteCount < 1) return mText;
if (System.Text.Encoding.Default.GetByteCount(mText) <= byteCount)
{
return mText;
}
else
{
byte[] txtBytes = System.Text.Encoding.Default.GetBytes(mText);
byte[] newBytes = new byte[byteCount - 6];
for (int i = 0; i < byteCount - 6; i++)
newBytes[i] = txtBytes[i];
string str = System.Text.Encoding.Default.GetString(newBytes);
if (str.Substring(str.Length - 1, 1) == "?")
str = str.Substring(0, str.Length - 1);
return str + "..."; //Replace("?","")替换字节不对应产生的问号
}
}
/// <summary>
/// 删除html标签
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string DealHtml(string str)
{
str = Regex.Replace(str, @"\<(img)[^>]*>|<\/(img)>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\<(table|tbody|tr|td|th|)[^>]*>|<\/(table|tbody|tr|td|th|)>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\<(div|blockquote|fieldset|legend)[^>]*>|<\/(div|blockquote|fieldset|legend)>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\<(font|i|u|h[1-9]|s)[^>]*>|<\/(font|i|u|h[1-9]|s)>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\<(style|strong)[^>]*>|<\/(style|strong)>", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\<a[^>]*>|<\/a>", "", RegexOptions.IgnoreCase);
后面还有 113 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
