mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
UPDATED: improving email address splitting for common comma case
This commit is contained in:
parent
9524963da6
commit
1e37e91eda
3 changed files with 17 additions and 1 deletions
|
@ -58,7 +58,7 @@ function extract_first_email_addr(str: string): string
|
|||
function split_mime_email_addresses(line: string): set[string]
|
||||
{
|
||||
local output = string_set();
|
||||
local addrs = find_all(line, /(\"[^"]*\")?[^,]+/);
|
||||
local addrs = find_all(line, /(\"[^"]*\")?[^,]+@[^,]+/);
|
||||
for ( part in addrs )
|
||||
{
|
||||
add output[strip(part)];
|
||||
|
|
|
@ -13,6 +13,11 @@ three@example.com,
|
|||
two@example.com,
|
||||
one@example.com
|
||||
}
|
||||
{
|
||||
three@example.com,
|
||||
two@example.com,
|
||||
one@example.com
|
||||
}
|
||||
one@example.com
|
||||
[one@example.com, two@example.com, three@example.com, one@example.com]
|
||||
{
|
||||
|
@ -26,9 +31,17 @@ john.smith@email.com
|
|||
john.smith@email.com,
|
||||
jane.doe@email.com
|
||||
}
|
||||
{
|
||||
"Smith, John" <john.smith@email.com>,
|
||||
"Doe, Jane" <jane.doe@email.com>
|
||||
}
|
||||
john.smith@email.com
|
||||
[john.smith@email.com, jane.doe@email.com]
|
||||
{
|
||||
john.smith@email.com,
|
||||
jane.doe@email.com
|
||||
}
|
||||
{
|
||||
"Smith, John" <john.smith@email.com>,
|
||||
"Doe, Jane" <jane.doe@email.com>
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ s = "one@example.com,two@example.com,three@example.com,one@example.com";
|
|||
print extract_first_email_addr(s);
|
||||
print extract_email_addrs_vec(s);
|
||||
print extract_email_addrs_set(s);
|
||||
print split_mime_email_addresses(s);
|
||||
s = "ieje one@example.com, eifj two@example.com, asdf three@example.com, one@example.com";
|
||||
print extract_first_email_addr(s);
|
||||
print extract_email_addrs_vec(s);
|
||||
|
@ -19,7 +20,9 @@ s = "\"Smith, John\" <john.smith@email.com>, \"Doe, Jane\" <jane.doe@email.com>"
|
|||
print extract_first_email_addr(s);
|
||||
print extract_email_addrs_vec(s);
|
||||
print extract_email_addrs_set(s);
|
||||
print split_mime_email_addresses(s);
|
||||
s = "\"Smith, John\" <john.smith@email.com>,\"Doe, Jane\" <jane.doe@email.com>";
|
||||
print extract_first_email_addr(s);
|
||||
print extract_email_addrs_vec(s);
|
||||
print extract_email_addrs_set(s);
|
||||
print split_mime_email_addresses(s);
|
Loading…
Add table
Add a link
Reference in a new issue