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 :
  4. ---- for style attribute -----
  5. in the Find box :
  6. (<[^>]*)style\s*=\s*('|")[^\2]*?\2([^>]*>)
  8. in the Replace box :
  9. $1$3
  11. so the following
  12. <a href="" style="color:red;">Click here</a>
  13. will be reduced to
  14. <a href="" >Click here</a>
  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


RSS Icon Subscribe to comments

You need to login to post a comment.