For REGEX, I am wondering how I would clear all HTML tags entered except for the simple ones, such as <a>, <b>, <i>, <pre>. I know that I can use this regex to exclude all html charicters, but I am not sure how I would go about only removing some, and deleting the others while conserving the content inside. Thanks!
-
2Have you considered using an HTML parser instead?johnsyweb– johnsyweb2012-02-26 04:06:11 +00:00Commented Feb 26, 2012 at 4:06
-
If regex is absolutely necessary, please state so. Otherwise, use a built in PHP function.Shea– Shea2012-02-26 04:18:23 +00:00Commented Feb 26, 2012 at 4:18
Add a comment
|
1 Answer
See the second parameter in :
Essentially, you can call this function and list the tags you don't' want to be stripped.
1 Comment
Shea
It's not the requested regex, but regex is a but redundant for this. I agree that
strip_tags should be used for this, and question should be revised to, "Is there a way to only allow certain HTML tags in PHP?"