Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1091
  • Last Modified:

Regular Expression for chain mail message.

Hello Experts,

I am trying to write a regular expression to block chain mails. The current line I am trying to detect is "send this to at least 10 people" however I want to match based on any number of people and ignores case. I am currently using Ironport as our mail filtering solution. Here is what I have so far:

\Qsend this to at least\E [0-9]

Also, does anyone have any other tricks to catch chain mails.. Thanks
0
itsecurityteam
Asked:
itsecurityteam
  • 2
  • 2
1 Solution
 
Ionut A. TudorPHP ProgrammerCommented:
below regex will match any of the following:
send this to at least 10 people
send this to at 10 people
send   this   to  10 people
send   to  14 people
send   to   people
Hope it helps. Cheers

/send(?:\s{1,}this)?\s{1,}to(?:\s{1,}at)?(?:\s{1,}least)?[\s0-9]{1,}people/im

Open in new window

0
 
itsecurityteamAuthor Commented:
I like this however it does not ignore case. Can you write it to ignore the upper or lowercase of any letter? I checked the documentation on the Ironport and it uses Python for its regular expression. Dont know if this helps.
0
 
Ionut A. TudorPHP ProgrammerCommented:
This should work with lower or upper letters.
Cheers

if re.search(r"send(?:\s{1,}this)?\s{1,}to(?:\s{1,}at)?(?:\s{1,}least)?[\s0-9]{1,}people", subject, re.IGNORECASE | re.MULTILINE):

Open in new window

0
 
itsecurityteamAuthor Commented:
Thank you for your prompt response!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now