Using Regex Tester: practical guide
Build a pattern step by step
Start with a simple pattern that matches one example, then widen it. Test against several samples, including ones that should not match, because a pattern that matches too much is as wrong as one that matches too little.
Common causes of surprises
Quantifiers are greedy by default, so .* swallows as much as it can; add ? to make it lazy. Without anchors ^ and $, a pattern can match inside a longer string. Flags such as global, case-insensitive and multiline change what is returned.
- Escape special characters such as . and ( when you mean them literally.
- Nested repeating groups can cause very slow matching on some inputs; keep patterns simple.