ID: 43772
Updated by: [EMAIL PROTECTED]
Reported By: php at linuxhosted dot net
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: n/a
PHP Version: 5.2.5
New Comment:
The compiled regexp is cached after the first use, no need to compile
it manually.
Previous Comments:
------------------------------------------------------------------------
[2008-01-06 19:41:16] php at linuxhosted dot net
Description:
------------
what I'm proposing is, adding a function (perhaps named preg_compile)
that would accept 1 string parameter $pattern.
the function would return a resource with the compiled pcre code which
could be used anywhere in the other preg_* functions where a string for
the pattern would be accepted.
this way if you need to do 1000s of pcre matches of the same pattern(s)
on different data, it would not require internally doing pcre_compile()
over and over, saving very valuable cpu time.
Reproduce code:
---------------
<?php
$pattern = preg_compile("/s[i1]mpl[e3] pattern here/i"); // returns a
new type of resource
if (preg_match($pattern, "simple pattern here")) // which can then be
used anywhere the normal string pattern could be
echo "pattern matches\n";
?>
Expected result:
----------------
well, obviously if this feature was added i'd expect to see:
pattern matches
Actual result:
--------------
since this is not actually implemented i'd just get a fatal error :P
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43772&edit=1