Don't write regex without a sandbox
Trying to write a non-trivial regex straight into your code is like trying to debug a SQL query without a REPL. You can do it. You shouldn't.
Pro habit: build the pattern in a tester, paste it into your code only when it works.
Three testers worth knowing
regex101.com — the standard. Pick a flavor (PCRE2, Python, JavaScript, Go), paste your pattern, paste your test strings, see live highlighting, named-group breakdown, step-by-step explanation, and a debugger that walks the engine state. Free. No login needed for basic use.
regexr.com — friendlier UI, slightly less detail. Good for quick checks.
debuggex.com — visualizes your pattern as a railroad diagram (the state machine from lesson 4 made visible). Useful when you're trying to *understand* a complex pattern, not just test it.
Built-in alternatives
If you live in a terminal, your tester is one of:
rg --debug 'PAT' file— see what RE2 thinks.- Python REPL:
import re; re.findall(r'PAT', text)— fastest sandbox if Python is your daily driver. echo "input" | grep -E 'PAT'— POSIX-only check.
Build patterns incrementally
Don't try to write the perfect 80-character pattern in one shot. Start with the simplest version that matches one example. Add specificity. Test. Add an edge case. Test. The pattern grows from a seed, not from a blueprint.