Skip to content

Instantly share code, notes, and snippets.

View atmason90's full-sized avatar

Andrew Mason atmason90

View GitHub Profile
@atmason90
atmason90 / regex-tutorial.md
Last active March 25, 2024 10:54
Regular Expression Tutorial - Matching a URL

Regular Expression Tutorial - Matching a URL

In this tutorial, we will examine a regular expression for matching a URL. Using this example, we can begin to build a basic understanding of regular expressions, what each component represents, how they can be implemented in code to define search patterns, and how they can be used to validate that certain strings match specific criteria.

Summary

As previously stated, the following regular expression can be used to validate that a string is, in fact, a URL

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