zoukankan      html  css  js  c++  java
  • 自己留着:正则表达式

    原文地址:http://m.cnblogs.com/39034/1593905.html?full=1

    RFC1378 http://www.ietf.org/rfc/rfc1738.txt

                #region Http

                stringlowalpha = @"[a-z]";

                stringhialpha = @"[A-Z]";

                //stringalpha = String.Format(@"({0}|{1})", lowalpha, hialpha);

                stringalpha = String.Format(@"[a-zA-Z]", lowalpha, hialpha);

                stringdigit = @"[0-9]";

                stringsafe = @"(\$|-|_|\.|\+)";

                stringextra = @"(!|\*|'|\(|\)|,)";

                //stringhex = String.Format(@"({0}|A|B|C|D|E|F|a|b|c|d|e|f)", digit);

                stringhex = @"[0-9A-Fa-f]";

                //stringescape = String.Format(@"(%{0}{0})", hex);

                stringescape = @"(%[a-zA-Z0-9][a-zA-Z0-9])";

                stringunreserved = String.Format(@"({0}|{1}|{2}|{3})", alpha, digit,safe, extra);

                stringuchar = String.Format(@"({0}|{1})", unreserved, escape);

                stringreserved = @"(;|/|\?|:|@|&|=)";

                stringxchar = String.Format(@"({0}|{1}|{2})", unreserved, reserved,escape);

                stringdigits = String.Format(@"({0}+)", digit);

                //stringalphadigit = String.Format(@"({0}|{1})", alpha, digit);

                stringalphadigit = @"[a-zA-Z0-9]";

                stringdomainlabel = String.Format(@"({0}|{0}({0}|-)*{0})", alphadigit);

                stringtoplabel = String.Format(@"({0}|{0}({1}|-)*{1})", alpha,alphadigit);

                stringhostname = String.Format(@"(({0}\.)*{1})", domainlabel,toplabel);

                stringhostnumber = String.Format(@"{0}\.{0}\.{0}\.{0}", digits);

                stringhost = String.Format(@"({0}|{1})", hostname, hostnumber);

                stringport = digits;

                stringhostport = String.Format(@"({0}(:{1}){{0,1}})", host, port);

                stringhsegment = String.Format(@"(({0}|;|:|@|&|=)*)", uchar);

                stringsearch = String.Format(@"(({0}|;|:|@|&|=)*)", uchar);

                stringhpath = String.Format(@"{0}(/{0})*", hsegment);

                stringhttpurl = String.Format(@"http://{0}(/{1}(\?{2}){{0,1}}){{0,1}}",hostport, hpath, search);

                #endregion

                #region Ftp

                stringuser = String.Format(@"(({0}|;|\?|&|=)*)", uchar);

                stringpassword = String.Format(@"(({0}|;|\?|&|=)*)", uchar);

                stringlogin = String.Format(@"(({0}(:{1}){{0,1}}@){{0,1}}{2})",user, password, hostport);

                stringfsegment = String.Format(@"(({0}|\?|:|@|&|=)*)", uchar);

                stringftptype = @"(A|I|D|a|i|d)";

                stringfpath = String.Format(@"({0}(/{0})*)", fsegment);

                stringftpurl = String.Format(@"ftp://{0}(/{1}(;type={2}){{0,1}}){{0,1}}",login, fpath, ftptype);

                #endregion

                #region News

                stringgroup = String.Format(@"({0}({0}|{1}|-|\.|\+|_)*)", alpha,digit);

                stringarticle = String.Format(@"(({0}|;|/|\?|:|&|=)+@{1})", uchar,host);

                stringgrouppart = String.Format(@"(\*|{0}|{1})", group, article);

                stringnewsurl = String.Format(@"(news:{0})", grouppart);

                #endregion

                #region Nntpurl

                stringnntpurl = String.Format(@"nntp://{0}/{1}(/{2}){{0,1}}",hostport, group, digits);

                #endregion

                #region Telnet

                stringtelneturl = String.Format(@"telnet://{0}/{{0,1}}", login);

                #endregion

                #region Gopher

                stringgtype = xchar;

                stringselector = String.Format(@"({0}*)", xchar);

                stringgopherplus_string = String.Format(@"({0}*)", xchar);

                stringgopherurl = String.Format(@"gopher://{0}(/({1}({2}(%09{3}(%09{4}){{0,1}}){{0,1}}){{0,1}}){{0,1}}){{0,1}}",hostport, gtype, selector, search, gopherplus_string);

                #endregion

                #region Wais

                stringdatabase = String.Format(@"({0}*)", uchar);

                stringwtype = String.Format(@"({0}*)", uchar);

                stringwpath = String.Format(@"({0}*)", uchar);

                stringwaisdatabase = String.Format(@"(wais://{0}/{1})", hostport,database);

                stringwaisindex = String.Format(@"(wais://{0}/{1}\?{2})", hostport,database, search);

                stringwaisdoc = String.Format(@"(wais://{0}/{1}/{2}/{3})", hostport,database, wtype, wpath);

                stringwaisurl = String.Format(@"{0}|{1}|{2}", waisdatabase, waisindex,waisdoc);

                #endregion

                #region Mailto

                stringencoded822addr = String.Format(@"({0}+)", xchar);

                stringmailtourl = String.Format(@"mailto:{0}", encoded822addr);

                #endregion

                #region File

                stringfileurl = String.Format(@"file://({0}{{0,1}}|localhost)/{1}",host, fpath);

                #endregion

                #regionProsperourl

                stringfieldname = String.Format(@"({0}|\?|:|@|&)", uchar);

                stringfieldvalue = String.Format(@"({0}|\?|:|@|&)", uchar);

                stringfieldspec = String.Format(@"(;{0}={1})", fieldname, fieldvalue);

                stringpsegment = String.Format(@"(({0}|\?|:|@|&|=)*)", uchar);

                stringppath = String.Format(@"({0}(/{0})*)", psegment);

                stringprosperourl = String.Format(@"prospero://{0}/{1}({2})*", hostport,ppath, fieldspec);

                #endregion

                #region Otherurl

                //otherurlequal genericurl

                stringurlpath = String.Format(@"(({0})*)", xchar);

                stringscheme = String.Format(@"(({0}|{1}|\+|-|\.)+)", lowalpha,digit);

                stringip_schemepar = String.Format(@"(//{0}(/{1}){{0,1}})", login,urlpath);

                stringschemepart = String.Format(@"(({0})*|{1})", xchar, ip_schemepar);

                stringgenericurl = String.Format(@"{0}:{1}", scheme, schemepart);

                stringotherurl = genericurl;

               #endregion

  • 相关阅读:
    SQL注入检测方法
    WCF基础二
    WCF 基础框架
    ASP.NET MVC案例教程(七)
    ASP.NET MVC案例教程(六)
    ASP.NET MVC案例教程(四)
    ASP.NET MVC案例教程(五)
    ASP.NET MVC案例教程(二)
    ASP.NET MVC案例教程(三)
    实验五、单元测试
  • 原文地址:https://www.cnblogs.com/newdefence/p/1869219.html
Copyright © 2011-2022 走看看