EmailDiscussions.com  

Go Back   EmailDiscussions.com > Email Service Provider-specific Forums > FastMail Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Stay in touch wirelessly

FastMail Forum All posts relating to FastMail.FM should go here: suggestions, comments, requests for help, complaints, technical issues etc.

Reply
 
Thread Tools
Old 3 Sep 2019, 09:54 PM   #16
hbs
Junior Member
 
Join Date: Jul 2016
Posts: 8
:domain takes the domain part from the address without the "@".

So "@linkedin.com" would never match.
hbs is offline   Reply With Quote
Old 3 Sep 2019, 09:55 PM   #17
JamesHenderson
Essential Contributor
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 467
got it - thanks!
JamesHenderson is offline   Reply With Quote
Old 3 Sep 2019, 10:23 PM   #18
SideshowBob
Member
 
Join Date: Jan 2017
Posts: 74
Quote:
Originally Posted by xyzzy View Post

"@linkedin\\.com$"

As a regex that will never work. That does not test for an email address local part (part before the @). So the complete regex would be

"[email protected](.*\\.)?linkedin\\.com$"
You need the * with :matches because you need to match the whole string. regexes match on substings unless you anchor them, hence the "$". Your ".+" makes no difference at all here.
SideshowBob is offline   Reply With Quote
Old 3 Sep 2019, 10:28 PM   #19
JamesHenderson
Essential Contributor
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 467
so, using :domain, I got this to work which is fairly simple as no need to worry about the "@" anymore.
Code:
  address :domain :regex "From" "\\.*linkedin\\.com$",
JamesHenderson is offline   Reply With Quote
Old 3 Sep 2019, 10:30 PM   #20
hbs
Junior Member
 
Join Date: Jul 2016
Posts: 8
Quote:
Can't help with the why, but FM needs the double backslashes.
I got curious myself and found it. The double-backslash is actually defined in RFC 5228, section 2.4.2.

So, Fastmail aren't the ones to blame.
hbs is offline   Reply With Quote
Old 3 Sep 2019, 10:51 PM   #21
BritTim
The "e" in e-mail
 
Join Date: May 2003
Location: mostly in Thailand
Posts: 2,797
Quote:
Originally Posted by JamesHenderson View Post
so, using :domain, I got this to work which is fairly simple as no need to worry about the "@" anymore.
Code:
  address :domain :regex "From" "\\.*linkedin\\.com$",
You should be aware that the above code is exactly equivalent to
Code:
address :domain :regex "From" "linkedin\\.com$",
In both cases you are saying that the domain must end in linkedin.com with anything prior to this being irrelevant. Note that, if you want to ensure that the domain name is not something like xlinkedin.com or xxx.ylinkedit.com (correct, I guess, but maybe overkill) the correct solution depends on the precise details of the regex support provided. It can be quite tricky.
BritTim is offline   Reply With Quote
Old 3 Sep 2019, 10:58 PM   #22
JamesHenderson
Essential Contributor
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 467
Quote:
Originally Posted by JamesHenderson View Post
so, using :domain, I got this to work which is fairly simple as no need to worry about the "@" anymore.
Code:
  address :domain :regex "From" "\\.*linkedin\\.com$",
as did this:
Code:
address :regex "From" "[\\[email protected]]linkedin\\.com$",
...and I think this was what I was imagining from the start when I wrote:
Code:
address :matches "From" "*[[email protected]]linkedin.com",
JamesHenderson is offline   Reply With Quote
Old 3 Sep 2019, 11:00 PM   #23
JamesHenderson
Essential Contributor
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 467
Quote:
Originally Posted by BritTim View Post
You should be aware that the above code is exactly equivalent to
Code:
address :domain :regex "From" "linkedin\\.com$",
In both cases you are saying that the domain must end in linkedin.com with anything prior to this being irrelevant. Note that, if you want to ensure that the domain name is not something like xlinkedin.com or xxx.ylinkedit.com (correct, I guess, but maybe overkill) the correct solution depends on the precise details of the regex support provided. It can be quite tricky.
agh, yes of course- thanks for pointing that out.
So I don't really want to use :domain as I want the first character to be either an "@" or a "."

...works out for me because actually I am putting these rules into the UI (minus the double slashes as FM adds them for me) and I cannot find a way to have "domain in the UI.
JamesHenderson is offline   Reply With Quote
Old 3 Sep 2019, 11:01 PM   #24
JamesHenderson
Essential Contributor
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 467
Smile

thanks to everyone for their kind and friendly support in solving my problem and helping me learn in the process :-)
JamesHenderson is offline   Reply With Quote
Old 3 Sep 2019, 11:11 PM   #25
SideshowBob
Member
 
Join Date: Jan 2017
Posts: 74
Quote:
Originally Posted by JamesHenderson View Post
Thanks, xyzzy.

I got the gist of your code (thanks). but my question was specifically why two slahes were needed in succession. I can see that Fastmail translates my single slash into two, but why? ...I cannot see any reference to double-shlashing having a special meaning in regex (it seems to me that the first slash escapes the second slash).
It's because the escaping is happening at two separate levels.

In sieve a \ is used to escape the double quote character that's normally the string delimiter, and a literal \ itself has to be escaped as \\. Other backslashes are ignored. This is done before the regex string is passed to the regex library.
SideshowBob is offline   Reply With Quote
Old 4 Sep 2019, 12:17 AM   #26
JamesHenderson
Essential Contributor
 
Join Date: Jan 2003
Location: Oxfordshire, UK
Posts: 467
Brilliant - thanks for that explanation, SideshowBob
JamesHenderson is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 07:46 AM.

 

Copyright EmailDiscussions.com 1998-2013. All Rights Reserved. Privacy Policy