I'm trying to build a complex regular expression, and I recall reading an article on email address validation where each portion of the regular expression was broken down into much simpler, individual regular expressions like:
email := <localpart>@<domainpart>
localpart := (?:<mailbox>\+)?(<username>)
domainpart := <domainname>\.<tld>
etc...
But I can't seem to find any documentation on anything similar. Is there a similar valid, programmatic syntax, or am I mis-remembering some RFC-style pseudocode?
Notes:
- I'm not trying to validate an email address, I know about
filter_var()
andFILTER_VALIDATE_EMAIL
. - I've added the perl tag since in my travels someone said "I think perl has something like that"