RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Pattern Title
Expression
^([a-z0-9]+([\-a-z0-9]*[a-z0-9]+)?\.){0,}([a-z0-9]+([\-a-z0-9]*[a-z0-9]+)?){1,63}(\.[a-z0-9]{2,7})+$
Description
[Note: this regex was tested with Macromedia's ColdFusion MX. I'm sure it'll need some massaging to work with other regex engines.] Of the few domain validating regular expressions I found in my search I didn't find a single one that reliably handled multiple levels of subdomains or TLDs. So, I wrote one and thoroughly tested it. There are a ton of matching and non-matching examples that need to be included to show the completeness of this regex. Non-matching: -.domain.com, -a.domain.com, -domain.com, domain-.com, any domain where the portion before the tld is greater than 63 characters. Matching: a.domain.com, a-a.domain.com, a--a.domain.com, a--defg.com, domain.co.uk.
Matches
800-med-alert.com | jump.to | archive-3.www.regexlib.com
Non-Matches
example | a-.domain.com | http://regexlib.com/
Author Rating: Not yet rated. Jeff Howden
   Displaying page 1 of 1 pages; Items 1 to 1

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials