Regular expression to match all domain names except admin / www / mail
I am new to regex, but give me this, I need to find a match:
a.com
b.com
c.com
aa.com
admin.com
www.com
mail.com
vg.com
As a result, I found a regular expression for all domains except admin / www / mail.
I wrote this:
[a-zA-Z0-9]+.com
But how to exclude admin, mail, www
I've tried this:
^(www|mail|admin)[a-zA-Z0-9]+.com
But it doesn't work
source to share
try it
\w+(?<!admin|mail|www)\.com
Here are some tests http://www.rubular.com/r/frRl1ucR8J
Further reading on regular expressions: http://www.regular-expressions.info/tutorial.html
And the trick I used is called Negative LookBehind http://www.regular-expressions.info/lookaround.html
source to share
Don't just rule out some things, but here is a link to help:
http://www.codinghorror.com/blog/2005/10/excluding-matches-with-regular-expressions.html
Can the replacement be replaced first? First you can find / replace to eliminate lines that match the things you want to skip, then use your regex.
source to share