Skip to content

Instantly share code, notes, and snippets.

@mambru82
mambru82 / url-regex-tutorial.md
Created April 19, 2021 02:49
regex tutorial for URL matching

Matching a URL using regular expressions - a tutorial

The following gist gives a thorough description of the central components in matching a given URL utilizing regular expressions in Javascript.

Summary

Regex uses a sequence of characters to define a specific search pattern. In the URL matching regex, regex matches any valid URL.

/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
@mambru82
mambru82 / regex-tutorial.md
Last active April 19, 2021 02:51
Gist describing a regex search function

Matching a URL using regular expressions - a tutorial

The following gist gives a thorough description of the central components in matching a given URL utilizing regular expressions in Javascript.

Summary

Regex uses a sequence of characters to define a specific search pattern. In the URL matching regex, regex matches any valid URL.

/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/