note 26231 deleted from function.preg-replace by sniper
| From: | sniper@php.net | Date: | Sun, 07 Sep 2003 22:04:55 +0000 |
| Subject: | note 26231 deleted from function.preg-replace by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-55698@lists.php.net to get a copy of this message | ||
Note Submitter: my@mail.com
----
Me again,
Meanwhile one long night further I found some documentation on the internet.
http://www.tjhsst.edu/~dhyatt/perl/exA.html
Further more I rewrote the above script to a more flexible script.
$text = preg_replace("/(<.*?)(=)(?!\"|\')(.*?)(>|[[:space:]])/is",
"\\1\\2\"\\3\"\\4",$text);
It now will replace ALL instances of HTML tags without quatation marks AND it is not dependable on
lower or uppercase anymore (the /is did the trick). Repeat the code for more instances within the
TAG.
eg. <FONT COLOR=#444444 SIZE=3 BGCOLOR=#456743>
You'll have to repeat the string for 3 times to fix the TAG!
Result:
<FONT COLOR="#444444" SIZE="3" BGCOLOR="#456743">
Ciao!
Joeri