Regular Expressions 101

Community Patterns

123...6

Simple URL validation

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 - 6 months ago