Skip to content

Instantly share code, notes, and snippets.

@triple-j
Last active August 29, 2015 14:20
Show Gist options
  • Save triple-j/d96dc8b147cea0965415 to your computer and use it in GitHub Desktop.
Save triple-j/d96dc8b147cea0965415 to your computer and use it in GitHub Desktop.
Simple Email Name Extract REGEX
/(?:\"?([^\"]*)\"?\s+<?)?([^<>]*)(?:>)?/
@triple-j
Copy link
Author

Given: "Bob Smith" <[email protected]>
Will output:

array (
  0 => '"Bob Smith" <[email protected]>',
  1 => 'Bob Smith',
  2 => '[email protected]',
)

Given: [email protected]
Will output:

array (
  0 => '[email protected]',
  1 => '',
  2 => '[email protected]',
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment