compiling a regexp
| From: | David T-G | Date: | Thu, 19 Sep 2002 03:19:47 +0000 |
| Subject: | compiling a regexp | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-116840@lists.php.net to get a copy of this message | ||
Hi, all --
Can I compile a regexp as I can in perl?
We have various possible values that we want to strip out of a string and
we store them in an array so that users can update with their own. To
wit:
$noadobe =
array
(
"File written by Adobe Photoshop",
"LEAD Technologies Inc." ,
"more pesky text" ,
) ;
We want to make it easy on the users, so we're not going to figure any
regular expressions belong in there; I'll just use a greedy .* to suck up
everything that starts with any of these matches.
In my code I can certainly
$noadoberegexp = "(" . join("|",$noadobe) . ").*" ;
and then
$cleanstring = eregi_replace("$noadoberegexp","",$stripstring) ;
but 1) I haven't tested this code yet :-) and 2) I wonder if I'll run
into long runtimes when we get lots of strings to match.
TIA & HAND
:-D
--
David T-G * It's easier to fight for one's principles
(play) davidtg@justpickone.org * than to live up to them. -- fortune cookie
(work) davidtgwork@justpickone.org
http://www.justpickone.org/davidtg/ Shpx gur
Pbzzhavpngvbaf Qrprapl Npg!