Helpful regexs for stripping extranous styling

Content migration is a pain, particularly when you are charged with copying content from an old html site into a new framework. Often times, old content comes with the baggage of inline css styling, which wreaks havoc on your pretty new site design. Here's a handful of helpful regexs that I use to strip out undeed inline styling, while still preserving the html element structure.

To strip out span tags: <span[^>]+> Follow up to strip out the close tags:

Strip out inline styling: style="[^"]+"

FYI:[] defines a character class, ^ excludes characters.

I think you get the idea.

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.