• 几个正则表达式


    1,验证IP地址: Regex regexIP = new Regex(@"^((0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})\.){3}(0|1[0-9]{0,2}|2[0-9]{0,1}|2[0-4][0-9]|25[0-5]|[3-9][0-9]{0,1})$");

    2,验证guid: strQuery = Regex.Replace(strTemp, @"(\{[A-Fa-f0-9]{8}(-[A-Fa-f0-9]{4}){3}-[A-Fa-f0-9]{12}\})+", _guID, RegexOptions.Singleline);

    3,用空格替换/*注释*/: string strQueryTemp2 = Regex.Replace(strQueryTemp1, @"\/\*(\s|.)*?\*\/[;|\s\$+]", "", RegexOptions.Singleline);

    4,用空格替换掉数据库的 --注释 : strQuery = Regex.Replace(strQueryTemp2, @"--[^\n]*", "", RegexOptions.Singleline);

    5,验证端口: Regex regexPort = new Regex(@"^([0-5]?\d?\d?\d?\d|6[0-4]\d\d\d|65[0-4]\d\d|655[0-2]\d|6553[0-5])$");

    6,验证名称只能(中英文数字或-空格):

    (1):!Regex.IsMatch(this.Name.Text.Trim(), "^[ |\u4e00-\u9fa5a-zA-Z0-9|-]+$") ||

    (2):Regex.IsMatch(this.Name.Text.Trim(), "^[\u3040-\u309F\u30A0-\u30FF]") ||

    (3):Name.Text.Length != Name.Text.Trim().Length

    7,验证域名:

    !Regex.IsMatch(this.txtDomainName.Text.Trim(), "^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$") ||
    this.txtDomainName.Text.Length != this.txtDomainName.Text.Trim().Length

  • 相关阅读:
    office(PPT、Word、Excel)功能目录
    《数商》笔记
    笔记模板
    如何运用思维导图安排考生读书计划(增订版)
    自制桌面图片
    selenium+AutoIt
    selenium中应用问题解决
    mysql卸载
    vue每次修改刷新当前子组件
    vue与dajngo
  • 原文地址:https://www.cnblogs.com/tangtang615/p/1420808.html
Copyright © 2020-2023  润新知