Posted By

bjornredemption on 09/19/10


Tagged

regex


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Remove html tag attributes with Regex find and replace in Dreamweaver


 / Published in: Regular Expression
 

Use this regex search in Dreamweaver's find/replace to remove any html tag attributes

  1. If you find yourself having to grab content off older websites and have to remove inline styles - or worse inline javascript! - use this code in Dreamweaver's find and replace dialog :
  2.  
  3.  
  4. ---- for style attribute -----
  5. in the Find box :
  6. (<[^>]*)style\s*=\s*('|")[^\2]*?\2([^>]*>)
  7.  
  8. in the Replace box :
  9. $1$3
  10.  
  11. so the following
  12. <a href="http://www.website.com" style="color:red;">Click here</a>
  13. will be reduced to
  14. <a href="http://www.website.com" >Click here</a>
  15.  
  16.  
  17. ---------
  18. actually you could remove any tag attribute by replacing the 'style' with the name of the attribute you want to remove

Report this snippet  

You need to login to post a comment.