dannyyy
dannyyy

Reputation: 1784

Looking for a regex pattern

I need a regex which match in all cases the associate email address of the from 'tag'.

Examples:

From: =?iso-8859-1?Q?First_Second_=28Company_Inc=29?=
    <[email protected]>

From: =?iso-8859-1?Q?First_Second_=28Company_Inc=29?=
 <[email protected]>

From: =?iso-8859-1?Q?First_Second_=28Company_Inc=29?=
 [email protected]

From: =?iso-8859-1?Q?First_Second_=28Company_Inc=29?=
    [email protected]

From: [email protected]

From: <[email protected]>

I tried different patterns (RegexOptions.Multiline) but probably took a false approach. The one listed below matches not to the second to last.

^From: ([^<>\r\n]+([ |\r\n|\r|\n][\t| ])?)?[<]?([^<>]+)[>]?$

Thanks in advance.

Kinde regards,
Danny

Upvotes: 0

Views: 130

Answers (1)

dannyyy
dannyyy

Reputation: 1784

After some further try and error I got the pattern

From:( [^<>\r\n]+[ |\r\n|\r|\n]?)?[\t| ]+[<]?([^<>]+?@[^>\r\n]+)[>]?

Upvotes: 1

Related Questions