Is there a function somewhere in emacs already to parse RFC
2822-formatted email addresses? I don't particularly care for the
obsolete parts, but would like to be able to parse things like "John
Smith" <john.smith@example.com>
into ("John Smith"
. "john.smith@example.com")
. I've gotten the following regex working,
but I figured gnus or someone must have done this properly already.
(defconst fov-email-address-regex
(let* ((cfws `(? (any space)))
(atom `(any alpha digit "!#$%&*+/=?^_`{|}'~-"))
(quoted-pair `(: "\"" (* (or (not (any "\"\\")) (: "\\" nonl))) "\""))
(display-name `(* (or ,cfws ,atom ,quoted-pair)))
(addr-spec `(group-n 1 (: (+ (any alpha digit ".!#$%&'*+-/=?\^_`{|}~-"))
"@"
(+ (any alpha digit "-")) (+ (: "." (+ (any alpha digit "-")))))))
(angle-addr `(: ,cfws "<" ,addr-spec ">" ))
(name-addr `(: (? ,display-name) ,angle-addr))
(mailbox `(or ,addr-spec ,name-addr))
(mailbox-list `(: ,mailbox (* (: "," ,mailbox))))
(group `(: ,display-name ":" (or ,cfws ,mailbox-list) ";" ,cfws))
(address `(or ,mailbox ,group)))
(rx-to-string `(: string-start ,address string-end) t))
"Regex used to parse an RFC 2822 email address.")
lisp/mail/mail-parse.el
.ietf-drums-parse-address
is what I needed. If you answer, I'll accept :)mail-header-parse-address
frommail-parse
instead of its current valueietf-drums-parse-address
fromietf-drums
, as the former comprises a standard interface and the latter may become obsolete in the future.