473,382 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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 13903
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Justin Koivisto | last post by:
OK, I found a thread that help out from a while back (Oct 9, 2002) to give me this pattern: `(((f|ht)tp://)((+)(+)?@)?()+(:\d+)?(\/+)?)`i OK, all is well and good with this until the URL is...
2
by: Muumac | last post by:
I have problem with large textfiles! When I load over 4MB xml and then try to preg_match something in this I get always FALSE! I have <File>....</File> tags in XML. Between tags is files contents...
0
by: awebguynow | last post by:
I ran across this code, and it kind of made me nervous: (as an email validator) if ( !preg_match("/.*\@.*\..*/", $_POST) | preg_match("/(\)/", $_POST) ) 1) from bitwise experience with "C",...
2
by: splodge | last post by:
I have a simple regular expression: {1,5}x{1,5} Which is designed to detect the width and height of an image from a string, as in: foo 100x100 bar However, when I run this with...
5
by: Mark Woodward | last post by:
Hi all, I'm trying to validate text in a HTML input field. How do I *allow* a single quote? // catch any nasty characters (eg !@#$%^&*()/\) $match = '/^+$/'; $valid_srch = preg_match($match,...
6
by: mantrid | last post by:
Hello Found this piece of code using preg_match to check file types during upload of files. $allowed_file_types = "(jpg|jpeg|gif|bmp|png)"; preg_match("/\." . $allowed_file_types . "$/i",...
13
by: chadsspameateremail | last post by:
I might have found a problem with how preg_match works though I'm not sure. Lets say you have a regular expression that you want to match a string of numbers. You might write the code like this:...
3
by: Happy Face | last post by:
Hi, All, I encountered this strange problem while using function preg_match. The following is the php code. when I set the line: $text = str_repeat('*', 12500); preg_match will return 0 for...
2
ashitpro
by: ashitpro | last post by:
Hi everybody.. The error I am getting is "Warning: preg_match() : Compilation failed: missing terminating ] " This happened because I'd supplied syntactically wrong regular expression to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.