QiFeng.ZWY.Utility/StringTools/StringValidHelper.cs

(开头部分) 2KB

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace QiFeng.LMSD.Utility
{
    /// <summary>
    /// 字符串验证工具
    /// </summary>
    public static class StringValidHelper
    {

        /**/
        ///  <summary> 
        /// 过滤sql中非法字符 
        ///  </summary> 
        ///  <param name="value">要过滤的字符串 </param> 
        ///  <returns>string </returns> 
        public static string Filter(string value)
        {
            if (string.IsNullOrEmpty(value)) return string.Empty;
            value = Regex.Replace(value, @";", string.Empty);
            value = Regex.Replace(value, @"'", string.Empty);
            value = Regex.Replace(value, @"&", string.Empty);
            value = Regex.Replace(value, @"%20", string.Empty);
            value = Regex.Replace(value, @"--", string.Empty);
            value = Regex.Replace(value, @"==", string.Empty);
            value = Regex.Replace(value, @" <", string.Empty);
            value = Regex.Replace(value, @">", string.Empty);
            value = Regex.Replace(value, @"%", string.Empty);

            return value;
        }

        /// <summary>
        /// 判断字符串中是否包含中文
        /// </summary>
        /// <param name="str">需要判断的字符串</param>
        /// <returns>判断结果</returns>
        public static bool HasChinese(this string str)
        {
            return Regex.IsMatch(str, @"[\u4e00-\u9fa5]");
        }

        /// <summary>
        /// 判断字符串长度是否溢出
        /// 分含中文长度与不含中文长度
        /// </summary>
        /// <param name="str"></param>
        /// <param name="maxCnLength"></param>
        /// <param name="maxNoCnLength"></param>
        /// <returns></returns>
        public static bool CheckOverLengthIncludeChinese(this string str, int maxCnLength, int maxNoCnLength)
        {
            if (str.HasChinese())
            {
                if (str.Length > maxCnLength)
后面还有 17 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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