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:
Anthony Gatlin
|
Source |
Anthony Gatlin |
Your Rating |
|
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 ".*$")