ID: 9321
Updated by: stas
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Closed
Bug Type: *Regular Expressions
Assigned To:
Comments:
Regexps with two .* is doing _a real lot_ of backtracking
and is _VERY_ slow. In your example you can easily replace
it with strstr and a bit of string fiddling.
Previous Comments:
---------------------------------------------------------------------------
[2001-02-17 15:11:39] [EMAIL PROTECTED]
I have an own e-mail source parser script for an archive engine. It has been working
for a long time without errors, but it was crashed yesterday.
I have found the problem: eregi() halts with a 13k long text. This is same with PHP
4.0.3 Windows and PHP 4.0.4pl Debian Linux.
I include a short script to show it:
--------
<?php
$cuts = array("_______________________________________________n");
$lines = file('workmail.txt');
foreach ($lines as $l) {
$text .= $l . "n";
}
$text = str_replace(chr(13),'',$text);
echo strlen($text) . "nn";
foreach ($cuts as $c) {
$ok = true;
$cnt = 0;
while ($ok && $cnt < 15) {
echo $c . "n";
$regs[2] = '';
eregi("(.*)($c)(.*)",$text,$regs);
$text = $regs[1] . $regs[3];
$ok = ($regs[2] == $c) && ($c != ''); // originally it was "$ok = $regs[2]", but
I was trying to find the problem so I have changed
$cnt++;
echo strlen($text) . "nn";
}
}
?>
----------
This is the result with windows/php4.0.3:
"
13238
_______________________________________________
13190
_______________________________________________
<br>
<b>Fatal error</b>: Maximum execution time of 30 seconds exceeded in
<b>C:Webroottesteregitest.php4</b> on line <b>19</b><br>
"
----
The result with PHP 4.0.4pl - Debian
"
13239
_______________________________________________
13191
_______________________________________________
13143
_______________________________________________
<br>
<b>Fatal error</b>: Maximum execution time of 180 seconds exceeded in
<b>/home/mage/public_html/test/test.php4</b> on line <b>18</b><br>
"
------
I think this is a bug, but that happend only with a specific text file. I should send
it.
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9321&edit=2
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]