user13410977
user13410977

Reputation:

How can I exclude a specific string from a regular expression?

I have the following rule to match any website that begins with two numbers:

([0-9]+[0-9]+[a-z]+)+(\.net|\.com)

It matches domains like:

99abc.com 78c.net

How can I exclude from this rule a list of specific websites, for example

10ofthose.com 180post.net etc...?

Upvotes: 1

Views: 1288

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 521178

You could a negative lookahead blacklist to the start of the pattern:

^(?!(?:10ofthose\.com|180post\.net)$)[0-9]{2}[a-z]+\.(?:net|com)$

Demo

Upvotes: 3

Related Questions