Bonus

Regex tester

Pattern, flags and highlighted matches

Live preview
Build a regular expression tester with Tailwind CSS. Use a max-w-2xl card with a heading and a muted line. The pattern row is a bordered field with monospaced slashes rendered as muted addons on either side of the input, and a small flags input after the closing slash. Under it, a textarea of test text pre-filled with a few lines. Below, a result panel showing the subject text with every match wrapped in a highlighted span, then a match list where each entry shows an index, the matched text in monospace and any capture groups as small pills. A status line reports the match count or a red parse error. Then add JavaScript that compiles the pattern on every keystroke inside a try-catch, escapes the subject before injecting highlights, always forces the global flag for the highlight pass, guards against zero-length matches looping forever, and lists up to twenty matches.