Re: regexp to substitute incremental strings
| From: | liljim | Date: | Fri, 25 Jan 2002 16:21:49 +0000 |
| Subject: | Re: regexp to substitute incremental strings | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82125@lists.php.net to get a copy of this message | ||
Hi mweb,
try this:
<?
$string = "<IMG SRC=\"C:\dir1\dir2\dir3\img1.gif\">
blah blah blah some text, html markup...
<IMG SRC=\"img2.jpg\">
blah blah again";
$string = preg_replace("/<IMG SRC=\".*?([0-9])\.(gif|jpg)\">/i",
"<IMG
SRC=\"UNIQUE_CODE_0$1.$2\">", $string);
echo nl2br($string);
?>
~James
"Mweb" <> wrote in message ...
Hello,
What is the right regexp to handle this, either in a while loop (how?)
or all by itself? The closer I've come to the solution is: