54 / 80 · 12 Programming for QA · Regex and Parsing← prev⊞ allnext →☰ Read as one page
7.3Essential Regex Patterns for QA
| Pattern | Matches | Use Case |
|---|---|---|
\d{3}-\d{4} |
123-4567 | Phone number fragments |
\b[A-Z]{2,}\b |
ERROR, WARN | Log level extraction |
"[^"]*" |
Any quoted string | Extract values from raw text |
\d{4}-\d{2}-\d{2} |
2024-03-15 | ISO date extraction |
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z]{2,}\b |
email@example.com | Email validation |
\b\d{1,3}(\.\d{1,3}){3}\b |
192.168.1.1 | IP address extraction |
TX-\d+ |
TX-98712 | Transaction/order ID extraction |
v\d+\.\d+\.\d+ |
v2.4.1 | Version number extraction |
[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12} |
UUID format | UUID extraction |