From: sam_bravard at yahoo dot com
Operating system: all
PHP version: 5.0.3
PHP Bug Type: Feature/Change Request
Bug description: preg_compile() Need way to pre-compile regex
Description:
------------
PHP is missing the ability to pre-compile regex expressions and then use
the pre-compiled regex.
This is a _major_ performance issue (100x) when processing files or text
streams with regex's. In PHP you have to recompile the regex for each
line you process... a major waste of cpu time.
See Perl, .NET or Java's regex support for an example of how to use
precompiled regex's.
Perhaps PHP can add something like the following and just overload the
first argument to preg_match and friends:
$precompiled_expression = preg_compile("regex expression");
preg_match($precompiled_expression, $sourcedata, $matches);
Reproduce code:
---------------
$precompiled_expression = preg_compile("regex expression");
preg_match($precompiled_expression, $sourcedata, $matches);
Actual result:
--------------
Function doesn't exist... sorely needed for performance.
--
Edit bug report at http://bugs.php.net/?id=32470&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32470&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=32470&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=32470&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32470&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32470&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32470&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32470&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32470&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32470&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32470&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=32470&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=32470&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32470&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32470&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32470&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32470&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32470&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32470&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32470&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32470&r=mysqlcfg