Solved

how to clean up unneccessary html tags

Posted on 2009-04-06
3
164 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

691 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