Browse the docs

parseAddresses

Reads an email address list into records with name and email.

Details #

parseAddresses(text) reads a list such as Jane Smith <jane@x.com>, bob@y.org (the To or Cc line of an email) into a list of records with name and email. Commas and semicolons inside quotes ("Smith, Jane" <jane@x.com>) or angle brackets do not split the list, and a mailto: prefix is dropped.

Parameters #

Takes 1 argument. {{ parseAddresses(text) }}

Examples #

parseAddresses("Jane Smith <jane@x.com>, bob@y.org")
→ [ { "email" : "jane@x.com", "name" : "Jane Smith" }, { "email" : "bob@y.org", "name" : "" } ]
length(parseAddresses(header))
→ 2
Sample variableValue
headerJane <jane@x.com>, bob@y.org

Gotchas #

  • It never fails: pieces that are not an address are skipped, and no text gives an empty list.