?
Solved

how to clean up unneccessary html tags

Posted on 2009-04-06
3
Medium Priority
?
166 Views
Last Modified: 2012-05-06
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
Comment
Question by:amitbravo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 24076262
you can use a regular expression to strip out those things like:

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

Open in new window

0
 

Author Comment

by:amitbravo
ID: 24084426
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
 
LVL 48

Expert Comment

by:hernst42
ID: 24086090
no thats AFAIK not possible with a regular expression or that regular expresion if far beyond my knowledge.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question