preg_match(): Compilation failed: regular expression too large

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Clodoaldo Pinto

    preg_match(): Compilation failed: regular expression too large

    preg_match(): Compilation failed: regular expression too large at
    offset 0

    The regular expression is 34,745 bytes long.

    <?php
    $regExp = 'huge regexp with 34,745 bytes';
    echo '<pre>strlen($r egExp) = ', strlen($regExp) , "\n";
    echo preg_match($reg Exp, 'sudokusweb.com ');
    echo '</pre>';
    ?>

    This error shows in Fedora Core 5 - PHP 5.4.1

    The same code works in a shared host running PHP 4.3.11:



    The code including the regexp can be downloaded from:



    Regards, Clodoaldo Pinto

  • Andy Hassall

    #2
    Re: preg_match(): Compilation failed: regular expression too large

    On 4 Sep 2006 14:21:09 -0700, "Clodoaldo Pinto" <clodoaldo.pint o@gmail.com>
    wrote:
    >preg_match() : Compilation failed: regular expression too large at
    >offset 0
    >
    >The regular expression is 34,745 bytes long.
    >
    ><?php
    >$regExp = 'huge regexp with 34,745 bytes';
    >echo '<pre>strlen($r egExp) = ', strlen($regExp) , "\n";
    >echo preg_match($reg Exp, 'sudokusweb.com ');
    >echo '</pre>';
    >?>
    >
    >This error shows in Fedora Core 5 - PHP 5.4.1
    >
    >The same code works in a shared host running PHP 4.3.11:
    >
    >http://allthehosts.com/testregex.php
    >
    >The code including the regexp can be downloaded from:
    >
    >http://allthehosts.com/testregex.txt

    See the LIMITATIONS section of http://www.pcre.org/pcre.txt

    There are compile-time options that may allow longer expressions, possibly
    these differ between the two sites.

    However, that's one big beastie of an expression, most of which is just
    alternation - you *could* run it as a series of smaller expressions.

    --
    Andy Hassall :: andy@andyh.co.u k :: http://www.andyh.co.uk
    http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

    Comment

    • Clodoaldo Pinto

      #3
      Re: preg_match(): Compilation failed: regular expression too large

      Andy Hassall wrote:
      On 4 Sep 2006 14:21:09 -0700, "Clodoaldo Pinto" <clodoaldo.pint o@gmail.com>
      wrote:
      >
      preg_match(): Compilation failed: regular expression too large at
      offset 0

      The regular expression is 34,745 bytes long.
      See the LIMITATIONS section of http://www.pcre.org/pcre.txt
      The maximum length of a compiled pattern is 65539 (sic) bytes
      if PCRE
      is compiled with the default internal linkage size of 2.

      Then I suppose FC5 does not compile it with the default size of 2

      This is from phpinfo():

      Configure Command './configure' '--build=x86_64-redhat-linux'
      '--host=x86_64-redhat-linux' '--target=x86_64-redhat-linux-gnu'
      '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr'
      '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc'
      '--datadir=/usr/share' '--includedir=/usr/include'
      '--libdir=/usr/lib64' '--libexecdir=/usr/libexec'
      '--localstatedir=/var' '--sharedstatedir=/usr/com'
      '--mandir=/usr/share/man' '--infodir=/usr/share/info'
      '--cache-file=../config.cache' '--with-libdir=lib64'
      '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d'
      '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear'
      '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin'
      '--with-freetype-dir=/usr' '--with-png-dir=/usr'
      '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp'
      '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-png'
      '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr'
      '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp'
      '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem'
      '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars'
      '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos'
      '--enable-ucd-snmp-hack' '--with-unixODBC=shared ,/usr'
      '--enable-memory-limit' '--enable-shmop' '--enable-calendar'
      '--enable-dbx' '--enable-dio' '--with-mime-magic=/etc/httpd/conf/magic'
      '--without-sqlite' '--with-libxml-dir=/usr' '--with-xml'
      '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd'
      '--without-odbc' '--disable-dom' '--disable-dba' '--without-unixODBC'
      '--disable-pdo' '--disable-xmlreader' '--disable-xmlwriter'

      Regards, Clodoaldo Pinto

      Comment

      • Kimmo Laine

        #4
        Re: preg_match(): Compilation failed: regular expression too large

        "Clodoaldo Pinto" <clodoaldo.pint o@gmail.comwrot e in message
        news:1157404869 .431371.54580@e 3g2000cwe.googl egroups.com...
        preg_match(): Compilation failed: regular expression too large at
        offset 0
        >
        The regular expression is 34,745 bytes long.

        That's not a regular expression, that's an Operating System... What the heck
        are you trying to do with it? Validate the Universe? :-)


        --
        "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
        http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
        spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


        Comment

        • Clodoaldo Pinto

          #5
          Re: preg_match(): Compilation failed: regular expression too large

          Kimmo Laine wrote:
          "Clodoaldo Pinto" <clodoaldo.pint o@gmail.comwrot e in message
          news:1157404869 .431371.54580@e 3g2000cwe.googl egroups.com...
          preg_match(): Compilation failed: regular expression too large at
          offset 0

          The regular expression is 34,745 bytes long.
          >
          >
          That's not a regular expression, that's an Operating System... What the heck
          are you trying to do with it? Validate the Universe? :-)
          That is for a SMF Spam Black List Mod:


          I fixed it breaking the regexp into smaller pieces.

          Regards, Clodoaldo Pinto

          Comment

          Working...