please help really easy regex? RSS

1

I would like to match a subject which "starts with the word from, followed by one space, followed by a word, followed by one space, followed by another word, and that's all"

i'm missing something, i've tried:
^from.*[a-zA-Z][a-zA-Z]$
^from.*[ba-zA-Z\b].*[ba-zA-Z\b]$
^from.*[ba-zA-Z\b]\s[ba-zA-Z\b]$

any many, many variations...they all seem to match:
from oneword
from one word
from one word and others

thanks in advance!

by Bryon 4 years ago
2

@Bryon: also, as a follow up since i'm learning regex examples, how could i best match a subject which is only a date in thie format:

1/17/2015 3:04:07 PM
"one or two digits 1-12,
followed by a /,
followed by one or two digits 1-31,
followed by a /,
followed by a 4 digit number,
followed by a space,
followed by one or two digits 00-23,
followed by a :,
followed by a 2 digit number 00-59,
followed by a :,
followed by a 2 digit number 00-59,
followed by a space,
followed by AM or PM"

by Bryon 4 years ago
(in reply to this post)

3

@Bryon: Try

^from(\s[^\s\r\n]*){2}$

That is

beginning of string + "from" + (whitespace, followed by any character which is not whitespace or line break, any number of repetitions) twice + end of string

by Krisztián Fekete (Vamsoft) 4 years ago
(in reply to this post)

4

@Bryon: Try

^(\d{1,2}/){2}\d{4}\s\d{1,2}:\d{2}:\d{2}\s(A|P)M$

It does not limit the double-digits though (that would be very complex/overkill imho).

by Krisztián Fekete (Vamsoft) 4 years ago
(in reply to this post)

5

@Krisztián Fekete (Vamsoft): Hello

I'm trying to put this into practice and while this pattern would work in ORF, it would only match our keyword blacklist (subject) and act with that one set action

I'd like to be a little more clear to the senders, and to do that i'd put it in as a hub transport rule in Exchange - after ORF passes it.

Exchange doesn't like that regex (^from(\s[^\s\r\n]*){2}$) - it complains about the backslash being used in a way it doesn't understand

I know you're not here to support exchange, but because you are the regex expert, i was hoping you might be able to redefine that in a more "dumb" way so this inferior exchange filter can understand it? :)

by Bryon 4 years ago
(in reply to this post)

6

@Bryon: ORF uses the PCRE engine for regular expressions. Judging from the documentation of Exchange, its regex capabilities are very limited:

https://technet.microsoft.com/en-us/library/aa997187(v=exchg.141).aspx

Try the following alternatives:

^from\s(\w\w*)\s(\w\w*)$

^\d\d*/\d\d*/\d\d\d\d\s\d\d*:\d\d*:\d\d*\s(A|P)M$

by Krisztián Fekete (Vamsoft) 4 years ago
(in reply to this post)

New comment

Fill in the form below to add a new comment. All fields are required. If you are a registered user on our site, please sign in first.

Nickname:
Email address (will not be published):
Your comment:

ORF Technical Support

Configuring, installing and troubleshooting ORF.

News & Announcements

Your dose of ORF-related news and announcements.

Everything but ORF

Discuss Exchange and system administration with fellow admins.

Feature Test Program

Feature Test Program discussion. Membership is required to visit this forum.

ORF Beta

Join the great bug hunt of the latest test release.

Customer Service

Stay Informed