zoukankan      html  css  js  c++  java
  • 几个正则表达式

    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

  • 相关阅读:
    mysql 远程登陆不上
    hdu 5339 Untitled【搜索】
    SqlServer 书目
    passwordauthentication yes
    oracle 11g RAC ocfs2
    Oracle 11g RAC database on ASM, ACFS or OCFS2
    CentOS ips bonding
    Oracle 11g RAC features
    openStack 王者归来之 trivial matters
    openstack windows 2008 img
  • 原文地址:https://www.cnblogs.com/tangtang615/p/1420808.html
Copyright © 2011-2022 走看看