Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
.NET 7.0 (C#)

@"
(?<Protocol>(http(s)?)):\/\/(?<SubDomain>([a-zA-Z]{1,3}\.))?(?<Domain>[a-zA-Z0-9]{2,})\.(?<TopLevelDomain>[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})?)
"
gm

Description

Validates protocol, sub-domain, domain, and top-level domain. No port number and query string parameters validation is made.

Submitted by anonymous - a year ago