Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
brian_li
New Contributor

Regex negative lookahead not working

Hi All,

 

I am trying to use regex to catch some specific email address while excluding some and seems regex negative lookahead is not working in FortiMail. Can anyone confirm that or me just doing it wrong?

 

My regex is to search in header with line "start with from:" and end with "example.com", but ignore anything from @support.example.com

(?!^from:.*@support\.example\.com$)(^from:.*example\.com$)

 

Thanks a lot.

Brian

1 REPLY 1
rwpatterson
Valued Contributor III

brian.li wrote:

Hi All,

 

I am trying to use regex to catch some specific email address while excluding some and seems regex negative lookahead is not working in FortiMail. Can anyone confirm that or me just doing it wrong?

 

My regex is to search in header with line "start with from:" and end with "example.com", but ignore anything from @support.example.com

(?!^from:.*@support\.example\.com$)(^from:.*example\.com$)

 

Thanks a lot.

Brian

Try /^from:.*example\.com$/

Starts with "from:", ignores an unlimited amount in the middle, ends with "example.com". I escaped the dot in .com so it won't match any character in that space.

 

** Added: I just saw the second half where you already did that. Sorry not able to add more information. Not sure if Fortimail uses standard regex, but try square brackets instead? And use the pipe between. i.e.

[?!^from:.*@support\.example\.com$|^from:.*example\.com$]

This would equate to not matching on the first half or matching the second half.

 

Hope that helps.

Bob - self proclaimed posting junkie!
See my Fortigate related scripts at: http://fortigate.camerabob.com

Bob - self proclaimed posting junkie!See my Fortigate related scripts at: http://fortigate.camerabob.com
Labels
Top Kudoed Authors