Skip to content

Instantly share code, notes, and snippets.

@triple-j
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save triple-j/d96dc8b147cea0965415 to your computer and use it in GitHub Desktop.

Select an option

Save triple-j/d96dc8b147cea0965415 to your computer and use it in GitHub Desktop.
Simple Email Name Extract REGEX
/(?:\"?([^\"]*)\"?\s+<?)?([^<>]*)(?:>)?/
@triple-j
Copy link
Copy Markdown
Author

Given: "Bob Smith" <bob@company.com>
Will output:

array (
  0 => '"Bob Smith" <bob@company.com>',
  1 => 'Bob Smith',
  2 => 'bob@company.com',
)

Given: bob@company.com
Will output:

array (
  0 => 'bob@company.com',
  1 => '',
  2 => 'bob@company.com',
)

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