• 检查命名的规范性,防止输入危险字符


    using System.Text.RegularExpressions;

    public static bool CheckString(string inputString, int maxLength)
      {
       bool success=true;
    //   StringBuilder retVal = new StringBuilder();     ///构造临时字符串数组
       if ((inputString != null) && (inputString != String.Empty))
       {
        inputString = inputString.Trim();         ///清空字符串两段的空白符号
        if (inputString.Length > maxLength)
        {   ///设置字符串的长度
         inputString = inputString.Substring(0, maxLength);
        }
        for (int i = 0; i < inputString.Length; i++)
        {
         switch(inputString[i])          
         {
           ///去除危险字符串(\ ,/,:,*,?,",<,>,| )
          case  '*':case'|':case '<':case '>':case '/':case '\\':case ':': case '?':case '"':
           success=false; break;
          default:;break;
         }
        }
        
       }
       return success;
      }
  • 相关阅读:
    jQuery小技巧
    HTML5 学习指导
    js对象排序&&倒序
    JS 中如何判断字符串类型的数字
    JavaScript中function的多义性
    JS 继承
    45.oracle表类型、数据拆分、表分区
    44.oracle表空间的使用
    43.oracle同义词
    42.oracle物化视图
  • 原文地址:https://www.cnblogs.com/bbxie/p/569569.html
Copyright © 2020-2023  润新知