most complicated regex ever?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    I have to go potty
    • Aug 2002
    • 55756

    #1

    most complicated regex ever?

    post what you got ;)
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


    Totally Free Templates
  • vdbucks
    Monger Cash
    • Jul 2010
    • 2773

    #2
    What language?

    Comment

    • fris
      I have to go potty
      • Aug 2002
      • 55756

      #3
      any will do ;)
      Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


      Totally Free Templates

      Comment

      • u-Bob
        there's no $$$ in porn
        • Jul 2005
        • 33063

        #4
        grabbing url and anchor text the complicated way:

        @<[\s]*a[\s]*[^>]*?href[\s]*=[\"\’\s]*(.*?)[\"\’\s]*[^>]*?> (.*?)<[\s]*/[\s]*a[\s]*>@is

        Comment

        • goldassets
          So Fucking Banned
          • Apr 2011
          • 309

          #5
          Code:
          ^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[13-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$
          Last edited by goldassets; 04-25-2011, 08:48 AM.

          Comment

          • fris
            I have to go potty
            • Aug 2002
            • 55756

            #6
            Code:
            ^(?=\d)(?:(?:(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})|(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))|(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2}))($|\ (?=\d)))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$
            DateTime M/d/y hh:mm:ss

            Matches
            12/25/2003 | 08:03:31 | 02/29/2004 12 AM

            Non-Matches
            02/29/2003 1:34 PM | 13:23 PM | 24:00:00
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


            Totally Free Templates

            Comment

            • Barry-xlovecam
              It's 42
              • Jun 2010
              • 18083

              #7
              Friend of mine did this regex:

              Code:
              $xml =~ s#<(performerinfo)>(.*?)</\1>
                       #{
                           my ($tmp, $data) = ($2);
                           $tmp =~ s|<(\w+)><!\[CDATA\[(.*?)\]\]></\1>
                                    |{$data->{$1}=$2}|sgex;
                          push(@models, $data)
                       }#sgex;

              Comment

              • fris
                I have to go potty
                • Aug 2002
                • 55756

                #8
                Originally posted by Barry-xlovecam
                Friend of mine did this regex:

                Code:
                $xml =~ s#<(performerinfo)>(.*?)</\1>
                         #{
                             my ($tmp, $data) = ($2);
                             $tmp =~ s|<(\w+)><!\[CDATA\[(.*?)\]\]></\1>
                                      |{$data->{$1}=$2}|sgex;
                            push(@models, $data)
                         }#sgex;
                perl i take it?
                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                Totally Free Templates

                Comment

                • blackmonsters
                  Making PHP work
                  • Nov 2002
                  • 21018

                  #9
                  Originally posted by Barry-xlovecam
                  Friend of mine did this regex:

                  Code:
                  $xml =~ s#<(performerinfo)>(.*?)</\1>
                           #{
                               my ($tmp, $data) = ($2);
                               $tmp =~ s|<(\w+)><!\[CDATA\[(.*?)\]\]></\1>
                                        |{$data->{$1}=$2}|sgex;
                              push(@models, $data)
                           }#sgex;
                  My eye hurts now!


                  For sale : foslacs.com
                  Free Open Source Live Aggregated Cams Script

                  https://gfy.com/forum/your-business-needs/sell-and-buy-forum/31465316-foslacs-com-for-sale-all-rights-to-the-software-included

                  Comment

                  • Barry-xlovecam
                    It's 42
                    • Jun 2010
                    • 18083

                    #10
                    Originally posted by fris
                    perl i take it?
                    Yes, that is an XML parser ...

                    Comment

                    • V_RocKs
                      Damn Right I Kiss Ass!
                      • Nov 2003
                      • 32448

                      #11
                      how about stuff that just gets used daily?
                      Code:
                      if (!$page = preg_replace("#<script(.+?) src=\"\/#is", "<script$1 src=\"$baseURL", $page))
                      	{ $page = preg_replace("#<script(.+?) src=\"#is", "<script$1 src=\"$workingUrl", $page); }

                      Comment

                      • The Dawg
                        Confirmed User
                        • Apr 2002
                        • 2438

                        #12
                        Great now I know who to contact next time I need help.

                        Comment

                        • thepiper
                          Confirmed User
                          • Feb 2002
                          • 31

                          #13
                          Email regex

                          Too big to post here, but its the last page of Mastering Regular Expressions by O'Reilly.

                          Its 6,598 bytes long and matches email addresses.

                          Comment

                          • Barry-xlovecam
                            It's 42
                            • Jun 2010
                            • 18083

                            #14
                            This is an email regex i did years ago:

                            Code:
                            &ReadParse(*input);
                            $user_email = $input{'01)required-user_email'};
                            
                            if ($user_email =~ /(\w{1}[\w-.]*)\@([\w-.]+)/) {
                                $user_email = "$1\@$2";
                                if( $2 =~ /(domain\.com|domain\.com)/i){
                            	    &disallowed_domain;
                            	    exit;
                            }    
                            } else {
                                warn ("TAINTED DATA SENT BY $ENV{'REMOTE_ADDR'}: $user_email: $!");
                                $user_email = ""; # successful match did not occur
                                &illegal;
                                exit;
                            }
                             
                            
                            if ($user_email =~m:^(.*)\@\@(.*)\.(.*)$:) {
                            &BadFormat;
                            exit;
                            }
                            if ($user_email =~m:^(www\.):) {
                            &BadFormat2;
                            exit;
                            }
                            
                            if ($user_email =~m:^(.*)\@(.*)\.(.*)$:) { ...}
                            More understandable ...

                            Comment

                            • fris
                              I have to go potty
                              • Aug 2002
                              • 55756

                              #15
                              Code:
                              <?php
                              
                              function validate_email ($email) {
                                $regex='/^[\w!#$%&\'*+\/=?^`{|}~.-]+@(?:[a-z\d][a-z\d-]*(?:\.[a-z\d][a-z\d-]*)?)+\.(?:[a-z]+)$/iD';
                                
                                if (preg_match($regex, $email, $m)) { return $m[0]; }
                                return false;
                              }
                              
                              var_dump(validate_email('[email protected]'));
                              
                              ?>
                              Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                              Totally Free Templates

                              Comment

                              • u-Bob
                                there's no $$$ in porn
                                • Jul 2005
                                • 33063

                                #16
                                Code:
                                function validEmail($email)
                                {
                                   $isValid = true;
                                   $atIndex = strrpos($email, "@");
                                   if (is_bool($atIndex) && !$atIndex)
                                   {
                                      $isValid = false;
                                   }
                                   else
                                   {
                                      $domain = substr($email, $atIndex+1);
                                      $local = substr($email, 0, $atIndex);
                                      $localLen = strlen($local);
                                      $domainLen = strlen($domain);
                                      if ($localLen < 1 || $localLen > 64)
                                      {
                                         // local part length exceeded
                                         $isValid = false;
                                      }
                                      else if ($domainLen < 1 || $domainLen > 255)
                                      {
                                         // domain part length exceeded
                                         $isValid = false;
                                      }
                                      else if ($local[0] == '.' || $local[$localLen-1] == '.')
                                      {
                                         // local part starts or ends with '.'
                                         $isValid = false;
                                      }
                                      else if (preg_match('/\\.\\./', $local))
                                      {
                                         // local part has two consecutive dots
                                         $isValid = false;
                                      }
                                      else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain))
                                      {
                                         // character not valid in domain part
                                         $isValid = false;
                                      }
                                      else if (preg_match('/\\.\\./', $domain))
                                      {
                                         // domain part has two consecutive dots
                                         $isValid = false;
                                      }
                                      else if (preg_match('/\!/', $email))
                                      {
                                         // 
                                         $isValid = false;
                                      }
                                      else if (preg_match('/\$/', $email))
                                      {
                                         // 
                                         $isValid = false;
                                      }
                                      else if (preg_match('/\|/', $email))
                                      {
                                         // 
                                         $isValid = false;
                                      }
                                      else if
                                (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/',
                                                 str_replace("\\\\","",$local)))
                                      {
                                         // character not valid in local part unless 
                                         // local part is quoted
                                         if (!preg_match('/^"(\\\\"|[^"])+"$/',
                                             str_replace("\\\\","",$local)))
                                         {
                                            $isValid = false;
                                         }
                                      }
                                   }
                                   return $isValid;
                                }

                                Comment

                                • fris
                                  I have to go potty
                                  • Aug 2002
                                  • 55756

                                  #17
                                  Code:
                                  (?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
                                  )*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)
                                  ){3}))(?::(?:\d+))?)(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F
                                  \d]{2}))|[;:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
                                  2}))|[;:@&=])*))*)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{
                                  2}))|[;:@&=])*))?)?)|(?:ftp://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?
                                  :%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-
                                  fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-
                                  )*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?
                                  :\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))(?:/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!
                                  *'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'()
                                  ,]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)(?:;type=[AIDaid])?)?)|(?:news:(?:
                                  (?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;/?:&=])+@(?:(?:(
                                  ?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[
                                  a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3})))|(?:[a-zA-Z](
                                  ?:[a-zA-Z\d]|[_.+-])*)|\*))|(?:nntp://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[
                                  a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d
                                  ])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)/(?:[a-zA-Z](?:[a-zA-Z
                                  \d]|[_.+-])*)(?:/(?:\d+))?)|(?:telnet://(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+
                                  !*'(),]|(?:%[a-fA-F\d]{2}))|[;?&=])*)(?::(?:(?:(?:[a-zA-Z\d$\-_.+!*'()
                                  ,]|(?:%[a-fA-F\d]{2}))|[;?&=])*))?@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a
                                  -zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d]
                                  )?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?))/?)|(?:gopher://(?:(?:
                                  (?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:
                                  (?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+
                                  ))?)(?:/(?:[a-zA-Z\d$\-_.+!*'(),;/?:@&=]|(?:%[a-fA-F\d]{2}))(?:(?:(?:[
                                  a-zA-Z\d$\-_.+!*'(),;/?:@&=]|(?:%[a-fA-F\d]{2}))*)(?:%09(?:(?:(?:[a-zA
                                  -Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;:@&=])*)(?:%09(?:(?:[a-zA-Z\d$
                                  \-_.+!*'(),;/?:@&=]|(?:%[a-fA-F\d]{2}))*))?)?)?)?)|(?:wais://(?:(?:(?:
                                  (?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:
                                  [a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?
                                  )/(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))*)(?:(?:/(?:(?:[a-zA
                                  -Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))*)/(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(
                                  ?:%[a-fA-F\d]{2}))*))|\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]
                                  {2}))|[;:@&=])*))?)|(?:mailto:(?:(?:[a-zA-Z\d$\-_.+!*'(),;/?:@&=]|(?:%
                                  [a-fA-F\d]{2}))+))|(?:file://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]
                                  |-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:
                                  (?:\d+)(?:\.(?:\d+)){3}))|localhost)?/(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'()
                                  ,]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(
                                  ?:%[a-fA-F\d]{2}))|[?:@&=])*))*))|(?:prospero://(?:(?:(?:(?:(?:[a-zA-Z
                                  \d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)
                                  *[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?)/(?:(?:(?:(?
                                  :[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*)(?:/(?:(?:(?:[a-
                                  zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&=])*))*)(?:(?:;(?:(?:(?:[
                                  a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&])*)=(?:(?:(?:[a-zA-Z\d
                                  $\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[?:@&])*)))*)|(?:ldap://(?:(?:(?:(?:
                                  (?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?:
                                  [a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))?
                                  ))?/(?:(?:(?:(?:(?:(?:(?:[a-zA-Z\d]|%(?:3\d|[46][a-fA-F\d]|[57][Aa\d])
                                  )|(?:%20))+|(?:OID|oid)\.(?:(?:\d+)(?:\.(?:\d+))*))(?:(?:%0[Aa])?(?:%2
                                  0)*)=(?:(?:%0[Aa])?(?:%20)*))?(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F
                                  \d]{2}))*))(?:(?:(?:%0[Aa])?(?:%20)*)\+(?:(?:%0[Aa])?(?:%20)*)(?:(?:(?
                                  :(?:(?:[a-zA-Z\d]|%(?:3\d|[46][a-fA-F\d]|[57][Aa\d]))|(?:%20))+|(?:OID
                                  |oid)\.(?:(?:\d+)(?:\.(?:\d+))*))(?:(?:%0[Aa])?(?:%20)*)=(?:(?:%0[Aa])
                                  ?(?:%20)*))?(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))*)))*)(?:(
                                  ?:(?:(?:%0[Aa])?(?:%20)*)(?:[;,])(?:(?:%0[Aa])?(?:%20)*))(?:(?:(?:(?:(
                                  ?:(?:[a-zA-Z\d]|%(?:3\d|[46][a-fA-F\d]|[57][Aa\d]))|(?:%20))+|(?:OID|o
                                  id)\.(?:(?:\d+)(?:\.(?:\d+))*))(?:(?:%0[Aa])?(?:%20)*)=(?:(?:%0[Aa])?(
                                  ?:%20)*))?(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))*))(?:(?:(?:
                                  %0[Aa])?(?:%20)*)\+(?:(?:%0[Aa])?(?:%20)*)(?:(?:(?:(?:(?:[a-zA-Z\d]|%(
                                  ?:3\d|[46][a-fA-F\d]|[57][Aa\d]))|(?:%20))+|(?:OID|oid)\.(?:(?:\d+)(?:
                                  \.(?:\d+))*))(?:(?:%0[Aa])?(?:%20)*)=(?:(?:%0[Aa])?(?:%20)*))?(?:(?:[a
                                  -zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))*)))*))*(?:(?:(?:%0[Aa])?(?:%2
                                  0)*)(?:[;,])(?:(?:%0[Aa])?(?:%20)*))?)(?:\?(?:(?:(?:(?:[a-zA-Z\d$\-_.+
                                  !*'(),]|(?:%[a-fA-F\d]{2}))+)(?:,(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-f
                                  A-F\d]{2}))+))*)?)(?:\?(?:base|one|sub)(?:\?(?:((?:[a-zA-Z\d$\-_.+!*'(
                                  ),;/?:@&=]|(?:%[a-fA-F\d]{2}))+)))?)?)?)|(?:(?:z39\.50[rs])://(?:(?:(?
                                  :(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.)*(?:[a-zA-Z](?:(?
                                  :[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:\d+)){3}))(?::(?:\d+))
                                  ?)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))+)(?:\+(?:(?:
                                  [a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))+))*(?:\?(?:(?:[a-zA-Z\d$\-_
                                  .+!*'(),]|(?:%[a-fA-F\d]{2}))+))?)?(?:;esn=(?:(?:[a-zA-Z\d$\-_.+!*'(),
                                  ]|(?:%[a-fA-F\d]{2}))+))?(?:;rs=(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA
                                  -F\d]{2}))+)(?:\+(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))+))*)
                                  ?))|(?:cid:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?:@&=
                                  ])*))|(?:mid:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?:@
                                  &=])*)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[;?:@&=]
                                  )*))?)|(?:vemmi://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z
                                  \d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\
                                  .(?:\d+)){3}))(?::(?:\d+))?)(?:/(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a
                                  -fA-F\d]{2}))|[/?:@&=])*)(?:(?:;(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a
                                  -fA-F\d]{2}))|[/?:@&])*)=(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d
                                  ]{2}))|[/?:@&])*))*))?)|(?:imap://(?:(?:(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+
                                  !*'(),]|(?:%[a-fA-F\d]{2}))|[&=~])+)(?:(?:;[Aa][Uu][Tt][Hh]=(?:\*|(?:(
                                  ?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[&=~])+))))?)|(?:(?:;[
                                  Aa][Uu][Tt][Hh]=(?:\*|(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2
                                  }))|[&=~])+)))(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[
                                  &=~])+))?))@)?(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])
                                  ?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:\.(?:
                                  \d+)){3}))(?::(?:\d+))?))/(?:(?:(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:
                                  %[a-fA-F\d]{2}))|[&=~:@/])+)?;[Tt][Yy][Pp][Ee]=(?:[Ll](?:[Ii][Ss][Tt]|
                                  [Ss][Uu][Bb])))|(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))
                                  |[&=~:@/])+)(?:\?(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[
                                  &=~:@/])+))?(?:(?:;[Uu][Ii][Dd][Vv][Aa][Ll][Ii][Dd][Ii][Tt][Yy]=(?:[1-
                                  9]\d*)))?)|(?:(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[&=~
                                  :@/])+)(?:(?:;[Uu][Ii][Dd][Vv][Aa][Ll][Ii][Dd][Ii][Tt][Yy]=(?:[1-9]\d*
                                  )))?(?:/;[Uu][Ii][Dd]=(?:[1-9]\d*))(?:(?:/;[Ss][Ee][Cc][Tt][Ii][Oo][Nn
                                  ]=(?:(?:(?:[a-zA-Z\d$\-_.+!*'(),]|(?:%[a-fA-F\d]{2}))|[&=~:@/])+)))?))
                                  )?)|(?:nfs:(?:(?://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-
                                  Z\d])?)\.)*(?:[a-zA-Z](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?))|(?:(?:\d+)(?:
                                  \.(?:\d+)){3}))(?::(?:\d+))?)(?:(?:/(?:(?:(?:(?:(?:[a-zA-Z\d\$\-_.!~*'
                                  (),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/(?:(?:(?:[a-zA-Z\d\$\-_.!~*'(),
                                  ])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?)))?)|(?:/(?:(?:(?:(?:(?:[a-zA-Z\d
                                  \$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/(?:(?:(?:[a-zA-Z\d\$\
                                  -_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?))|(?:(?:(?:(?:(?:[a-zA-
                                  Z\d\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*)(?:/(?:(?:(?:[a-zA-Z\d
                                  \$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?)))
                                  Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                                  Totally Free Templates

                                  Comment

                                  • uno
                                    RIP Dodger. BEST.CAT.EVER
                                    • Dec 2002
                                    • 18450

                                    #18
                                    regex has often been the bane of my existence.
                                    -uno
                                    icq: 111-914
                                    CrazyBabe.com - porn art
                                    MojoHost - For all your hosting needs, present and future. Tell them I sent ya!

                                    Comment

                                    • raymor
                                      Confirmed User
                                      • Oct 2002
                                      • 3745

                                      #19
                                      I wish I were on my computer so I could pull up some doozies.

                                      This one took three of us weeks to refine in 1997. It seems so simple now:
                                      ^http(s)?://([a-z0-9]+\.)*mysite.com(:[0-9]+)?(/|$)
                                      Last edited by raymor; 02-26-2012, 04:17 PM.
                                      For historical display only. This information is not current:
                                      support&#64;bettercgi.com ICQ 7208627
                                      Strongbox - The next generation in site security
                                      Throttlebox - The next generation in bandwidth control
                                      Clonebox - Backup and disaster recovery on steroids

                                      Comment

                                      • okok
                                        Confirmed User
                                        • Jan 2003
                                        • 502

                                        #20
                                        Oh come on amateurs, someone post an email validator.

                                        Comment

                                        • scouser
                                          marketer.
                                          • Aug 2006
                                          • 2280

                                          #21
                                          saw this one ages ago for validating email addresses. no idea if it works...

                                          The regular expression to validate email addresses (possibly multiple in to:, cc: and bcc: form) (from RFC 822) is pretty beefy; definitely the longest non-trivial regular expression that I have seen. Unfortunately, it seems that there are a lot of sites out there on the internet that do not use this regular expression or an equivalent validation as I have encountered far too many sites that do not accept [email protected] as a valid email address.

                                          (??:\r\n)?[ \t])*(???:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t] )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??: \r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?? ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*))*@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0 31]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\ ](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+ (???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?: (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n) ?[ \t])*)*\<(??:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\ r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n) ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t] )*))*(?:,@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])* )(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t] )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*) *??:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+ |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r \n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???: \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t ]))*"(??:\r\n)?[ \t])*))*@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031 ]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\]( ??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(? ??:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?? :\r\n)?[ \t])*))*\>(??:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?? ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)? [ \t]))*"(??:\r\n)?[ \t])*)*??:\r\n)?[ \t])*(???:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]| \\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<> @,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|" (?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*))*@(??:\r\n)?[ \t] )*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(? :[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[ \]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000- \031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|( ??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*)*\<(??:\r\n)?[ \t])*(?:@(?:[^()<>@,; :\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([ ^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\" .\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\ ]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*(?:,@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\ [\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\ r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\] |\\.)*\](??:\r\n)?[ \t])*))*)*??:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0 00-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\ .|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[^()<>@, ;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(? :[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*))*@(??:\r\n)?[ \t])* (?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\". \[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t])*(?:[ ^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\] ]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*\>(??:\r\n)?[ \t])*)(?:,\s*( ??:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ ".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*)(?:\.(? ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[ \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t ])*))*@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(? :\.(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+| \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*|(?: [^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\ ]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*)*\<(??:\r\n) ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\[" ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n) ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<> @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*(?:,@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@, ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\.(??:\r\n)?[ \t] )*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\ ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*)*??:\r\n)?[ \t])*)? (?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\". \[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t])*)(?:\.(??: \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z|(?=[\[ "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(??:\r\n)?[ \t]))*"(??:\r\n)?[ \t]) *))*@(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t]) +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*)(?:\ .(??:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(???:\r\n)?[ \t])+|\Z |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](??:\r\n)?[ \t])*))*\>(? ?:\r\n)?[ \t])*))*)?;\s*)

                                          Comment

                                          • Jacob[Soft]
                                            Confirmed User
                                            • Mar 2010
                                            • 873

                                            #22
                                            Originally posted by deadmoon
                                            saw this one ages ago for validating email addresses. no idea if it works...
                                            wow, look very complicated!

                                            Comment

                                            • martinsc
                                              Too lazy to set a custom title
                                              • Jun 2005
                                              • 27043

                                              #23
                                              this thread makes me dizzy....
                                              Make Money

                                              Comment

                                              • V_RocKs
                                                Damn Right I Kiss Ass!
                                                • Nov 2003
                                                • 32448

                                                #24
                                                another year of regex

                                                Comment

                                                • Bird
                                                  Confirmed User
                                                  • Jan 2005
                                                  • 4365

                                                  #25
                                                  I fucking hate regex...The most complicated thing I have ever been able to do is replace stuff in a series of numbers.

                                                  "[^"]*"

                                                  something like changing everything to <p>


                                                  <div id="1"></div>
                                                  <div id="2"></div>
                                                  <div id="3"></div>
                                                  <div id="4"></div>

                                                  Find
                                                  <div id="[^"]*"></div>
                                                  and replace with

                                                  <p id="[^"]*"></p>
                                                  results

                                                  <p id="1"></p>
                                                  <p id="2"></p>
                                                  <p id="3"></p>
                                                  <p id="4"></p>
                                                  ICQ:268731675

                                                  Comment

                                                  Working...