Common patterns to test against
- Email:
[^\s@]+@[^\s@]+\.[^\s@]+ - Digits only:
^\d+$ - URL:
https?:\/\/[^\s]+ - Whitespace-trimmed line:
^\s*(.*?)\s*$
Reading a regex piece by piece
Regular expressions read left to right as a sequence of instructions: ^ and $ anchor to the start/end of a line, \d/\w/\s match a digit/word-character/whitespace, +/* mean "one or more"/"zero or more" of whatever came before, and parentheses () capture a group you can reference later. Building a pattern in small pieces and testing each addition against real sample text — exactly what this tool is for — is far more reliable than writing the whole thing at once.
Greedy vs. lazy matching
By default, * and + are "greedy" — they match as much as possible. Adding a ? after them (like *?) makes them "lazy," matching as little as possible instead. This matters most with wildcards like .*, where greedy matching can accidentally span much further than intended across a long string.