DeskKit

Regex library

Regular expression for HTML tags

A teaching regex that finds opening and closing HTML tags. Not an HTML parser — use it to highlight, not to sanitize.

<\/?[A-Za-z][A-Za-z0-9]*(?:\s[^<>]*)?>

Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.

Flags

Highlighted matches

    How to use

    1. Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
    2. Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
    3. Paste your own corpus. Nothing is sent to a server.
    4. Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.

    You cannot parse HTML with a regex in the general case. You can still find tag-shaped spans in a snippet, which is useful when you want to highlight markup in a small demo.

    Do not use this to sanitize user HTML. A tag regex will miss comments, CDATA, SVG, and malformed markup that still executes in a browser.

    What this pattern will not do

    The g flag is on so every tag in the sample is listed.

    Script contents are not parsed; only the <script> and </script> tokens match.

    FAQ

    Can I strip tags with this?

    Not safely. Use a real sanitizer (DOMParser plus an allow-list, or a dedicated library) for untrusted HTML.

    Why is this still useful?

    For teaching, for linting known-good snippets, and for counting tags in a fixture.

    Is the sample text uploaded?

    No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.

    DeskKit is a static site. Interactive tools require JavaScript.