File:
Form.php
Current:
'email' => '/^\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/',
AI analysis:
Key points:
- ^\w+ → Local part must start with one or more “word” characters (letters, digits, underscore only — no plus sign allowed here).
- ([.-]?\w+)* → Allows optional dot or hyphen, followed by word characters, repeated any number of times.
- Domain part (@\w+([.-]?\w+)*) → Same dot/hyphen rules as local part.
- (.\w{2,3})+ → Top‑level domain must be 2 or 3 “word” chars only (e.g., .com, .nz) — cannot match .info or longer TLDs.
So loads of things that are not ideal with this regex.
Proposed:
'email' => '/^(?!.)(?!.*..)[A-Za-z0-9._%+-]+(?<!.)@(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-).)+[A-Za-z]{2,}$/',
Simple test: