BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 preg_replace() compares a pattern to a string and replaces that pattern with the provided replacement string. so you'll need to loop over the dis-allowed tags and use preg_replace, or build a crafty regular expression that does it in one shot. we'll stick to the easy version: $bad_tags = array("<BR>","<UL>","<WHATEVER>"); foreach ($bad_tags AS $a_bad_tag) { $pattern = "/^$a_bad_tag$/i"; // or something similar, i'm not regex pro... preg_replace($pattern, "<nocode>", $string); // Where $string is the content } echo $string; // replaced string. Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362880 Share on other sites More sharing options...
Yesideez Posted October 5, 2007 Share Posted October 5, 2007 A pattern something like this: preg_replace('(<br>|<ol>)','<bad>',$badcodes); That will remove <br>, <Br>, <bR>, <BR> and <ol> (case insensitive) with <bad> Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362882 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 don't we need /i in the pattern to denote case-insensitivity for preg_replace? examples here: http://us2.php.net/preg_replace Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362884 Share on other sites More sharing options...
Yesideez Posted October 5, 2007 Share Posted October 5, 2007 Probably yes, not on my usual machine and not got access to any of my source atm Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362885 Share on other sites More sharing options...
env3rt Posted October 5, 2007 Author Share Posted October 5, 2007 Correct solution: str_ireplace (but I don't have PHP 5) My solution: strtolower(); (Although there are other methods this was easiest) Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362910 Share on other sites More sharing options...
Yesideez Posted October 5, 2007 Share Posted October 5, 2007 Just note that if the input from the user has any capitals (like a name) then it'll be returned with all lower case. Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362911 Share on other sites More sharing options...
env3rt Posted October 5, 2007 Author Share Posted October 5, 2007 yea whatever, they aren't neccessary Link to comment https://forums.phpfreaks.com/topic/72009-solved-capital-letters-error/page/2/#findComment-362913 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.