Remove html tag attributes with Regex find and replace in Dreamweaver


/ Published in: Regular Expression
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.