Regular Expressions 101

Spo⁠nsors

Community Library

Community Library Entry

1

Regular ExpressionOpen Workspace

@"
(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+\-.]*):)?(?:\/\/)?(?<host>[^\/\s:?#]+)?(?::(?<port>\d+))?(?<path>\/[^\s?#]*)?(?:\?(?<query>[^\s#]*))?(?:#(?<fragment>[^\s]*))?
"
g

Description
Created·2026-08-01 18:18
Updated·2026-08-01 18:32
Type·Match
Flavor·.NET 7.0 (C#)

URL Parser Regex

Extracts common URL components.

Groups

GroupDescription
schemeProtocol scheme (http, ftp, etc.)
hostHost name or IP address
portPort number
pathPath part
queryQuery string
fragmentFragment identifier

Supports

  • http://example.com
  • ftp://example.com
  • //127.0.0.1:80/path
  • example.com/path?key=value#section
  • URI-like strings with schemes

Designed for .NET Regex. Extracts components but does not perform full RFC URI validation.

Submitted by Pavel Bashkardin
Open Workspace