⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringutil.cs

📁 网上销售订单管理系统借助现代信息技术和管理理论
💻 CS
字号:
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;//自定义验证表达式
using System.IO;
using System.Drawing.Imaging;
using System.Text;


/// <summary>
/// 对一些字符串进行操作的类
/// </summary>
public class StringUtil
{


    /// <summary>
    /// 判断输入是否数字
    /// </summary>
    /// <param name="num">要判断的字符串</param>
    /// <returns></returns>
    static public bool VldInt(string num)
    {
        #region
        try
        {
            Convert.ToInt32(num);
            return true;
        }
        catch { return false; }
        #endregion
    }
    /// <summary>
    /// 过滤输入信息
    /// </summary>
    /// <param name="text">内容</param>
    /// <param name="maxLength">最大长度</param>
    /// <returns></returns>
    public static string InputText(string text, int maxLength)
    {
        #region
        text = text.Trim();
        if (string.IsNullOrEmpty(text))
            return string.Empty;
        if (text.Length > maxLength)
            text = text.Substring(0, maxLength);
        text = Regex.Replace(text, "[\\s]{2,}", " ");	//two or more spaces
        text = Regex.Replace(text, "(<[b|B][r|R]/*>)+|(<[p|P](.|\\n)*?>)", "\n");	//<br>
        text = Regex.Replace(text, "(\\s*&[n|N][b|B][s|S][p|P];\\s*)+", " ");	//&nbsp;
        text = Regex.Replace(text, "<(.|\\n)*?>", string.Empty);	//any other tags
        text = text.Replace("'", "''");
        return text;
        #endregion
    }


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -