Regular Expression for chain mail message.

Posted on 2009-02-18
Last Modified: 2012-05-06
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
Question by:itsecurityteam
    LVL 14

    Expert Comment

    by:Ionut A. Tudor
    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


    Open in new window


    Author Comment

    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.
    LVL 14

    Accepted Solution

    This should work with lower or upper letters.

    if"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


    Author Closing Comment

    Thank you for your prompt response!

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
    I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now