Regular Expressions 101

Community Library

Community Library Entry

0

Regular ExpressionOpen Workspace

/
^(?<local>[a-zA-Z0-9\.!#$%&'*\-\/=?^_`{|}~"]+)(?:\.)?(?<routing>[a-zA-Z0-9\.!#$%&'*\-\/=?^_`{|}~+"]*)(?:@)(?<domain>(?:[a-zA-Z0-9\-[\]]*)(?:\.)(?:[a-zA-Z0-9\-[\]\.]*))$
/
gm

Description
Created·2018-08-15 08:38
Type·Match
Flavor·PCRE (Legacy)

This regex enforces the correct basic structure whilst only allowing permitted characters (RFC822) in both the local and domain parts. It permits + routing made popular by Gmail and allows for the + group to identified as routing. It allows all but the most extreme of valid email addresses i.e. "@" at symbols contained in quotes. A cautionary note, just because RFC permits these characters you own mail server may not accept them all.

Submitted by Anonymous
Open Workspace