Reputation: 15889
I have this pattern:
~^([a-z0-9]+[a-z0-9-]+[a-z0-9]+\.([a-z]+)(\.[a-z]+)?)$~i
It will match the following:
xxx.xxx
or
xxx.xxx.xxx
(number of x per doesn't matter)
How do I disallow xxx.xxx.xxx
if the set of characters before the first .
is wwww
?
For example, it should allow example.co
or example.co.uk
but it should not allow www.example.co
or www.example.co.uk
Upvotes: 0
Views: 499
Reputation: 33908
You can use a negative lookahead/lookbehind, eg:
~^((?!www\.)[a-z0-9]+[a-z0-9-]+[a-z0-9]+\.([a-z]+)(\.[a-z]+)?)$~i
Upvotes: 2