Domain Name Reg Ex
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngregexp' list.


Stewart Haddock
I need help with a Rex Ex that will check domain names.

Right now I have:     ^[a-zA-Z0-9\-\.]+\.(com|edu|net|gov|org)$

but this does not catch "-domain.com"

I tried:
^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]?\.(com|edu|net|gov|org)$

but it does not seem to work properly.

Any ideas?

Thanks,

Stewart Haddock

Reply to this message...
 
    
Stewart Haddock
Ai! I just realized the reg ex needs to also catch trailing hyphens.

Just to be complete. It needs to follow these rules.
Contain only alphanumeric characters (a-z and 0-9) and hyphens.
Begin and end with a letter or a number.
Contain no more than 67 characters including the domain type.

it needs to match
my.domain.com
my-domain.com
domain.com

and not match
.mydomain.com
-mydomain.com
mydomain-.com
mydomain..com

Thanks

Stewart

-----Original Message-----
From: Stewart Haddock
Sent: Tuesday, July 16, 2002 8:00 AM
To: aspngregexp
Subject: [aspngregexp] Domain Name Reg Ex

I need help with a Rex Ex that will check domain names.

Right now I have:     ^[a-zA-Z0-9\-\.]+\.(com|edu|net|gov|org)$

but this does not catch "-domain.com"

I tried:
^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]?\.(com|edu|net|gov|org)$

but it does not seem to work properly.

Any ideas?

Thanks,

Stewart Haddock

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com