Help with Regular Expression

Status
Not open for further replies.

MichaelC

Ars Legatus Legionis
34,233
I'm seeing a lot of spam from .eu domains lately. It's getting by our spam services. I'm looking to create a regexp filter based on content. I'm seeing messages with variations on the following:

If you cannot participate in the Ad following?
If you can't consider our Advertise-ment in this mail?
If your display can't load our Advertise-ment due to images?

There are a few more variations, but that;s the general direction of their wording

So I'm looking to create a regexp that will block a lot of this. What I'm trying to do is:

(?i)(If\syou\s)(one or more words wildcard expression)Advert\s(one or more words wildcard expression)\?$

The problem I have is trying to come up with a regexp that can capture the concept of there being one or more words between "If you" and "Ad" or "Advert" and also between "Ad" and the Question mark.

Thank you for any assistance.
 

Apteris

Ars Tribunus Angusticlavius
9,589
Subscriptor
I doubt you will solve this reliably with regexes. But the shorthand for word characters is \w and the word boundary metacharacter is \b. "One or more words wildcard expression" could be
Code:
([\w']+ )+
' for contractions such as "can't".

See this page--and that site in general--for more information on regexes than you ever wanted to have.
 
Status
Not open for further replies.