• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

how to clean up unneccessary html tags

I am using WYSIWYG ( tiny_mce) in my site.. i need to give privilege to users to use some html tags like <p> but if they paste unnecessary tags like <span style="font-weight: bold;"> which can not be estimated before hence str_replace() is not sufficient .

i think there can be a way like i select a portion from "<span"  to ... very next ">" and remove this from the content ?
0
amitbravo
Asked:
amitbravo
  • 2
1 Solution
 
hernst42Commented:
you can use a regular expression to strip out those things like:

$str = preg_replace("/\\<span[^>]+\\>/", '<span>', $str);

Open in new window

0
 
amitbravoAuthor Commented:
awesome ! it works .. could we use this tech. somehow to add rel="no follow" in <a href=.. tags .. do not repeat "no follow" if already added
0
 
hernst42Commented:
no thats AFAIK not possible with a regular expression or that regular expresion if far beyond my knowledge.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now