سازنده الگوی Regex با توضیح
Why this prompt matters
Regex without explanation is write-only code. Test cases make patterns verifiable and the explanation makes them maintainable.
What we use it for
Text processing
Prompt
Build a regex pattern for the described requirement. Provide: 1) The pattern with inline comments, 2) A plain-English explanation of each part, 3) 5 strings that should match, 4) 5 strings that should NOT match, 5) Edge cases to be aware of, 6) Performance considerations for large inputs.
Result
**Pattern**: `^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$`
**Explanation**: - `^` — Start of string - `(?=.*[A-Z])` — Lookahead: at least one uppercase letter - `(?=.*[a-z])` — Lookahead: at least one lowercase letter - `(?=.*\d)` — Lookahead: at least one digit - `(?=.*[@$!%*?&])` — Lookahead: at least one special character - `{8,}$` — Minimum 8 characters total
**Matches**: `P@ssw0rd`, `MyP@ss12` **Doesn't match**: `password`, `12345678`
Regex without explanation is write-only code. Test cases make patterns verifiable and the explanation makes them maintainable.
This prompt demonstrates a structured approach to text processing, producing consistent, high-quality results that can be iterated upon.