469,271 Members | 1,000 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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($regExp) = ', strlen($regExp), "\n";
echo preg_match($regExp, '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

Regards, Clodoaldo Pinto

Sep 4 '06 #1
4 12935
On 4 Sep 2006 14:21:09 -0700, "Clodoaldo Pinto" <cl*************@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($regExp) = ', strlen($regExp), "\n";
echo preg_match($regExp, '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 :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Sep 4 '06 #2
Andy Hassall wrote:
On 4 Sep 2006 14:21:09 -0700, "Clodoaldo Pinto" <cl*************@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

Sep 4 '06 #3
"Clodoaldo Pinto" <cl*************@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.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
sp**@outolempi.net || Gedoon-S @ IRCnet || rot13(xv***@bhgbyrzcv.arg)
Sep 5 '06 #4
Kimmo Laine wrote:
"Clodoaldo Pinto" <cl*************@gmail.comwrote in message
news:11*********************@e3g2000cwe.googlegrou ps.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:
http://www.simplemachines.org/commun...topic=109614.0

I fixed it breaking the regexp into smaller pieces.

Regards, Clodoaldo Pinto

Sep 5 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

22 posts views Thread by Justin Koivisto | last post: by
2 posts views Thread by Muumac | last post: by
reply views Thread by awebguynow | last post: by
2 posts views Thread by splodge | last post: by
5 posts views Thread by Mark Woodward | last post: by
6 posts views Thread by mantrid | last post: by
13 posts views Thread by chadsspameateremail | last post: by
3 posts views Thread by Happy Face | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.