Regex for Stripping HTML Tags From a String

Matches any HTML tag so it can be removed or replaced.

Published October 11, 2026

Matches any HTML tag so it can be removed or replaced.

Key points

  • Using regex to parse or sanitize HTML is fragile for complex/nested markup — for real sanitization, use a proper HTML parser library instead

Example

<[^>]*>
More General articles