App_Code/StringOper.cs

(开头部分) 11KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;


public class StringOper
{
	public StringOper()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}   

    public static string Substr(string stringToSub, int length)
    {
        length *= 2;
        Regex regex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled);
        char[] stringChar = stringToSub.ToCharArray();
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        int nLength = 0;
        bool isCut = false;
        for (int i = 0; i < stringChar.Length; i++)
        {
           
            
            if (regex.IsMatch((stringChar[i]).ToString()))
            {
                sb.Append(stringChar[i]);
                nLength += 2;
            }
            else
            {
                sb.Append(stringChar[i]);
                nLength = nLength + 1;
            }
          if (nLength > length)
            {
                isCut = true;
                break;
            } 
           
        }
        if (isCut)
            return sb.ToString() + "...";
        else
            return sb.ToString();
    }

    public static string Substr2(string stringToSub, int length)
    {
        length *= 2;
        Regex regex = new Regex("[\u4e00-\u9fa5]+", RegexOptions.Compiled);
后面还有 289 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。