A regular expression that “worked on one example” is one of the more expensive kinds of almost-right. It accepts [email protected] , then silently fails a plus-tag, a hyphen in the domain, or a Pakistani mobile number written with spaces. The cheap habit is to try the pattern against a messy block of real text before you paste it into code.
What the tester shows you
The Regex Tester on ToolSphare has a Regular expression field, a Test string box, three flags, a Test Regex button, then Matches and a Highlighted result .
The flags are the familiar JavaScript-style trio:
Global (g) — find every match, not only the first
Ignore case (i)
Multiline (m) — so ^ and $ can match at line ends, not only at the start and end of the whole string
The pattern placeholder is an email-like example: \b\w+@\w+\.\w+\b . That is a reasonable demonstration and a poor production email validator, which is a useful lesson in itself. \w+ does not know about plus-tags or all valid domains.…