RFC 5229 gives the following example:
if address :matches ["To", "Cc"] ["coyote@**.com", "wile@**.com"] { # ${0} is the matching address # ${1} is always the empty string # ${2} is part of the domain name ("ACME.Example") fileinto "INBOX.business.${2}"; stop;
And I do not understand why ${1} is always the empty string.
In this example, ${1} is the part before the < so using ${2} makes sense.
if header :matches "List-ID" "*<*@*" { fileinto "INBOX.lists.${2}"; stop; }
I am laso not sure why the first example used **.com instead of *.com (or is that the reason $1 doesn't contain anything because it is the first * of **?).
If so, my familiarity with the bash syntax for ** may have been my undoing.
If I had
# Given to kremels@kreme.com if address :matches ["To", "Cc"] ["*@*.*"] # ${1} would contain "kremels" # ${2} would contain "kreme" # ${3} would contain "com"
Yes?
-- "Are you pondering what I'm pondering?" "Sure, Brain, but how are we going to find chaps our size?"
On 10/21/20 11:15 AM, @lbutlr wrote:
RFC 5229 gives the following example:
if address :matches ["To", "Cc"] ["coyote@**.com", "wile@**.com"] { # ${0} is the matching address # ${1} is always the empty string # ${2} is part of the domain name ("ACME.Example") fileinto "INBOX.business.${2}"; stop;
And I do not understand why ${1} is always the empty string.
This is because of the text above that: "The wildcards match as little as possible (non-greedy matching)."
This example has two wildcards in a row (""**" doesn't mean anything special beyond that) -- and because the first "*" matches as little as possible, it matches nothing (the empty string). The second "*" matches everything between "@" and ".com".
The same thing happens with real regexps:
#!/usr/bin/perl $x = 'coyote@ACME.Example.COM'; $x =~ /coyote\@(.*?)(.*?)\.COM/; printf '$1 is "%s"; $2 is "%s"', $1, $2;
This will print:
$1 is ""; $2 is "ACME.Example"
I am laso not sure why the first example used **.com instead of *.com (or is that the reason $1 doesn't contain anything because it is the first * of **?).
Yes. The example is confusing because it makes it look like "**" is some magic thing you might want to use. It's not.
-- Robert L Mathews, Tiger Technologies, http://www.tigertech.net/
On 21 Oct 2020, at 18:04, Robert L Mathews lists@tigertech.com wrote:
On 10/21/20 11:15 AM, @lbutlr wrote:
I am laso not sure why the first example used **.com instead of *.com (or is that the reason $1 doesn't contain anything because it is the first * of **?).
Yes. The example is confusing because it makes it look like "**" is some magic thing you might want to use. It's not.
Thank you for confirming that. It's a really bad example.
-- "Are you pondering what I'm pondering?" "Yes, but why does the chicken cross the road, huh, if not for love? I do not know."
participants (2)
-
@lbutlr
-
Robert L Mathews