

Remove all "style" attributes from HTML text.
The best approach is to use an HTML / XML parser like Html Agility Pack to do this for you. Regular expression tester with syntax highlighting, PHP / PCRE & JS Support, contextual help, cheat sheet, reference, and searchable community patterns. Correctly parsing HTML is a very complex problem, and regular expressions are not a good tool for that. So the idea is to build a regular expression which can find all characters < > as a first incidence in a text, and after, using the sub function, we can. HTML is not a regular language and hence can't be 100% correctly parsed with a regex. You want a regular expression (regex) to match opening HTML tags such as,