Jump to content

Help with either Regex or StripTags?


ryancooper

Recommended Posts

Okay, i wasnt sure what section to post in but im leaning toward this one so here it is. I am trying to find the most efficient way to remove not all HTML but some, strip_tags lets you define allowable tags, i need to only remove certain ones, the problem is if i have <-- or << then strip_tags removes them with the rest of the HTML, Is there a way to only take tags that were opened and closed? Or in other words valid HTML? Or would i have to create a regex for every common HTML tag to have it stripped on its own? I'm new to PHP so the only work around ive been able to use is to str_replace every group of characters into a number, then strip_tags, then the number back into the associated characters... i realize this is a rigged work around and thats why im looking for something more efficient especially since any undefined groups get pulled.

 

One option which im not even sure is possible would be to match any HTML and if its a letter following the bracket have it stripped the only exception would be to also taking out / in closing brackets, this way <a herf would be stripped <b> </b> would both be stripped, so if the bracket is followed by any non A-Z character besides / it will be stripped, but if any bracket is followed by another bracket or various other symbols that arent used it will be left alone.

Link to comment
https://forums.phpfreaks.com/topic/232926-help-with-either-regex-or-striptags/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.