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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Regular Expression to Extract Standard Domain Name
Expression
(http[s]?://)?([A-Za-z0-9-]\.)*(?<domainName>([A-Za-z0-9-]+\.)[A-Za-z]{2,3})/?.$
Description
This regular expression is designed just to extract the domain name from a URL. A domain name may neither start with nor end with a dash. I didn't take the time to add in this check and am actually not sure that it could be easily done. Try it for yourself to understand why.
Matches
http://happycatfish.com/|http://happycatfish.com/our-work
Non-Matches
http://happycatfish.comm|http://happycatfish.c
Author Rating: The rating for this expression. Anthony Gatlin
Source Anthony Gatlin
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: some test cases fail
Name: Erwin
Date: 1/30/2016 5:43:00 AM
Comment:
The end of the regexp seems to be broken it says "/?.$" probably "/?.*$" was intended (which could then be shortened to ".*$")


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