ClaudeText processing

منشئ أنماط Regex مع الشرح

مشاركة:
منشئ أنماط Regex مع الشرح

لماذا تهم هذه المطالبة

Regex without explanation is write-only code. Test cases make patterns verifiable and the explanation makes them maintainable.

فيم نستخدمها

Text processing

المطالبة

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.

النتيجة

**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 بدون شرح هو كود يُكتب ولا يُقرأ. حالات الاختبار تجعل الأنماط قابلة للتحقق، والشرح يجعلها قابلة للصيانة. يوضح هذا الموجه نهجاً منظماً لمعالجة النصوص، ويُنتج نتائج متسقة وعالية الجودة يمكن البناء عليها وتطويرها.
مشاركة: