Sender blacklist with regular expression - ORF Forums

Sender blacklist with regular expression RSS Back to forum

1

Need some guidance with regex. We have two email address formats; and . The numbers on the second example range from 00-99. I would like to blacklist all senders that have any number between 00-99 at the end of their username before the @domain.com. Many thanks.

by Quilliby more than 10 years ago
2

@Quilliby: In that case, the regex would be

.*\d{2}@domain\.com$

This means "any characters, any number of repetitions; followed by 2 digits; followed by @domain.com, end of string". Note that "any characters, any number of repetitions" includes digits as well, so this will also match "". If the username part preceding the 2 digits should allow only letters (no numbers, dots, dashes, underscores, etc.), try

[a-z]*\d{2}@domain\.com$

If letters, dashes, dots, underscores are allowed in the username part, preceding the 2 digits, try:

[a-z_\.-]*\d{2}@domain\.com$

by Krisztián Fekete (Vamsoft) more than 10 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.

It will not be published.
hnp1 | hnp2