So i am working with some email header data, and for the to:, from:, cc:, and bcc: fields the email address(es) can be expressed in a number of different ways:
F
You could use regular expressions to try to separate this out, try this guy:
^(?[a-zA-Z0-9]+?),? (?[a-zA-Z0-9]+?),? (?[a-zA-Z0-9.-_<>]+?)$
will match: Last, First test@test.com
; Last, First
; First last test@test.com
; First Last
. You can add another optional match in the regex at the end to pick up the last segment of First, Last
after the email address enclosed in angled braces.
Hope this helps somewhat!
EDIT:
and of course you can add more characters to each of the sections to accept quotations etc for whatever format is being read in. As sjbotha mentioned, this could be difficult as the string that is submitted is not necessarily in a set format.
This link can give you more information about matching AND validating email addresses using regular expressions.