#32470 [Opn->Fbk]: preg_compile() Need way to pre-compile regex

From: Date: Mon, 28 Mar 2005 08:09:54 +0000
Subject: #32470 [Opn->Fbk]: preg_compile() Need way to pre-compile regex
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-75922@lists.php.net to get a copy of this message
ID: 32470 Updated by: tony2001@php.net Reported By: sam_bravard at yahoo dot com -Status: Open +Status: Feedback Bug Type: Feature/Change Request Operating System: all PHP Version: 5.0.3 New Comment: All pcre_* funcs do not compile expressions each time, they use cache of precompiled regexps. See pcre_get_compiled_regex_ex() in ext/pcre/php_pcre.c Or you're proposing something different? Previous Comments: ------------------------------------------------------------------------ [2005-03-28 10:04:13] sam_bravard at yahoo dot com 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 this bug report at http://bugs.php.net/?id=32470&edit=1

« previous php.bugs (#75922) next »