public static EmailContact Parse(string literals) { EmailContact contact; var emailMatch = Regex.Match(literals, "<.+>"); if (emailMatch.Success) { var email = emailMatch.Value.TrimAny(1); var cropped = literals.Replace(emailMatch.Value, string.Empty); var name = cropped.Trim(); name = name.TrimQuotes(); contact = new EmailContact(name, email); } else { contact = new EmailContact(literals.TrimQuotes()); } return(contact); }
public static EmailContact Parse(string literals) { EmailContact contact; var emailMatch = Regex.Match(literals, "<.+>"); if (emailMatch.Success) { var email = emailMatch.Value.TrimAny(1); var cropped = literals.Replace(emailMatch.Value, string.Empty); var name = cropped.Trim(); name = name.TrimQuotes(); contact = new EmailContact(name, email); } else { contact = new EmailContact(literals.TrimQuotes()); } return contact; }