note 26231 modified in function.preg-replace by didou

From: Date: Sat, 17 May 2003 16:34:39 +0000
Subject: note 26231 modified in function.preg-replace by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-48176@lists.php.net to get a copy of this message
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 --was-- 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 http://www.php.net/manual/en/function.preg-replace.php

« previous php.notes (#48176) next »