Regular Expressions 101

Community Patterns

URL Regex

2

Regular Expression
.NET (C#)

@"
^(?>(?'protocol'[a-zA-Z]+)://)?(?'domain'[a-zA-Z0-9.\-_]*)?(?>:(?'port'\d{1,5}))?/(?'path'[a-zA-Z0-9_\-%]+)(?:(?>\?(?'query'[a-zA-Z0-9_\-=&%]+))()|(?>#(?'anchor'[a-zA-Z0-9_\-%]+))()){0,2}$
"
gm

Description

Loading markdown...
Submitted by Jonathan - 5 months ago
(Last modified 5 months ago)