Highlight RegExp Matches in Text

Enter a pattern and see every match highlighted instantly.

The preview updates as you type. Ctrl + Enter highlights now.

Highlighted text

How to highlight regex matches

Paste your text into Your text, or press Load example, then type a JavaScript regular expression into Regular expression. Every match is wrapped in a <mark> tag and shown with a yellow marker in the preview. The HTML source below the preview can be copied or downloaded as an .html file. Everything runs in your browser, so nothing you paste is uploaded.

Examples

WhatInputPattern
Email pattern on contact text Email ada@example.com about the meeting at 10:30. \b\w+@\w[\w.-]*\.[A-Za-z]{2,}\b
Letter o highlighted hello world o
Tags shown as text, not run <b>hi</b> b

Limits and edge cases

  • Patterns use the JavaScript (ECMAScript) regex flavor, with optional ignore-case, multiline and dot-all flags.
  • The output is an HTML fragment: escaped text with matches wrapped in <mark> tags, not a full document.
  • All text is HTML-escaped before highlighting, so pasted tags or scripts display as text and never execute.
  • Zero-length matches are skipped, so patterns that can match empty strings cannot hang the page.

Frequently asked questions

How do I highlight regex matches?

Paste your text, type a regular expression into the pattern box, and every match is highlighted in the preview instantly. Copy the HTML source or download it.

What flags are supported?

Three checkboxes control the JavaScript flags: ignore case (i), multiline (m, so ^ and $ match at line edges), and dot-all (s, so . matches line breaks).

What does the HTML output look like?

The output is an HTML fragment where each match is wrapped in a <mark> tag, for example hell<mark>o</mark>. Paste it into any page to keep the yellow-marker styling.

Is the preview safe from scripts in my text?

Yes. All text is HTML-escaped before <mark> tags are added, so tags or scripts you paste are shown as text and never run.

Why does my pattern report no matches?

Check for typos, unescaped special characters, or missing flags. The status line shows the exact compile error when a pattern is invalid.

Is my text uploaded anywhere?

No. Highlighting runs in your browser with JavaScript and nothing is sent to a server. Inputs under 200 KB are kept in your browser's local storage so they are still there when you come back.