]> Sergey Matveev's repositories - public-inbox.git/blob - lib/PublicInbox/Address.pm
Merge branch 'thread-view-skel'
[public-inbox.git] / lib / PublicInbox / Address.pm
1 # Copyright (C) 2016 all contributors <meta@public-inbox.org>
2 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
3 package PublicInbox::Address;
4 use strict;
5 use warnings;
6
7 # very loose regexes, here.  We don't need RFC-compliance,
8 # just enough to make thing sanely displayable and pass to git
9
10 sub emails { ($_[0] =~ /([\w\.\+=\-]+\@[\w\.\-]+)>?\s*(?:,\s*|\z)/g) }
11
12 sub names {
13         map {
14                 tr/\r\n\t/ /;
15                 s/\s*<([^<]+)\z//;
16                 my $e = $1;
17                 s/\A['"\s]*//;
18                 s/['"\s]*\z//;
19                 $_ =~ /\S/ ? $_ : $e;
20         } split(/\@+[\w\.\-]+>?\s*(?:,\s*|\z)/, $_[0]);
21 }
22
23 1;