100% Client-Side β’ 0 B Data Leaves Browser
web
HTML Opening & Closing Tag Stripper Regex
Finds and strips opening, closing, and self-closing HTML/XML markup tags from rich text strings.
Regular Expression Pattern:
/<\/?[a-zA-Z][^>]*>/g
Valid Match Example:
<div class="active" data-id="10">
Invalid / Non-Match Example:
Plain text with no markup
Regex Syntax Breakdown & Explanation
- β’< : Opening bracket
- β’\/? : Optional forward slash for closing tags
- β’[a-zA-Z] : Starts with tag element letter
- β’[^>]*> : Matches all attribute characters until closing bracket
Implementation in Popular Languages
JavaScript / TypeScript
const regex = /<\/?[a-zA-Z][^>]*>/g;
const isValid = regex.test("<div class="active" data-id="10">");
console.log(isValid); // truePython (re)
import re pattern = r"<\/?[a-zA-Z][^>]*>" match = re.match(pattern, "<div class="active" data-id="10">") print(bool(match)) # True
Go (regexp)
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`<\/?[a-zA-Z][^>]*>`)
fmt.Println(re.MatchString("<div class="active" data-id="10">"))
}Frequently Asked Questions
Frequently Asked Questions
Everything you need to know regarding specifications, syntax, and security best practices.
The regular expression pattern is /<\/?[a-zA-Z][^>]*>/g. Finds and strips opening, closing, and self-closing HTML/XML markup tags from rich text strings.