The more sophisticated grammatical patterns in Perl, PCRE, and PHP can all manage to correctly parse RFC 5322 without a hitch. Python and C# should also be able to manage it, but they use a different syntax from those first three. However, if you are forced to use one of the many less powerful pattern-matching languages, then it’s best to use a real parser.