Title |
Test
Find
Specific Top-Level Domain (TLD)
|
Expression |
^.*(yourdomain.com).*$ |
Description |
Matches the TLD of a given domain (replace yourdomain.com with whatever domain you're trying to enforce).
I was writing an web application in which I wanted to to display a special message to visitors if and only if they were referred to my site by one specific site. However, because the specific site in question was highly dynamic, referring URLs were all over the place in terms of consistency and the only thing I knew I could count on 100% was the TLD (subdomains and file paths acceptable, so long as the TLD matches exactly). |
Matches |
yourdomain.com | http://www.yourdomain.com | http://subdomain.yourdomain.com/pages/manage/?act=4015876&ag=709254588456a |
Non-Matches |
your-domain.com | ourdomain.com | yourdomain.co |
Author |
Rating:
Matt Finazzo
|
Source |
|
Your Rating |
|
Title: Specific Top-Level Domain (TLD)
Name: Paul Randall
Date: 4/24/2008 10:25:30 AM
Comment:
Besides yourdomain.com, it matches yourdomainXcom, yourdomainYcom, and yourdomainZcom and a host of similar strings. Escaping the period, so the regex becomes
^.*(yourdomain\.com).*$
fixes the problem.