Skip to content

Instantly share code, notes, and snippets.

View Deiontre10's full-sized avatar

Taz Lowry Deiontre10

View GitHub Profile
@Deiontre10
Deiontre10 / regex-breakdown.md
Last active January 30, 2023 00:50
A regex used to match a URL

Regex E for Everyone

Regex or Regular Expressions are powerful patterns used to match, search, and manipulate text. Yet they are hard to master which is why I am creating a breakdown, that everyone can understand. They are widely used in various programming languages and tools for tasks such as data validation, pattern matching, and text processing.

Summary

The regex /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w\s\.-]*)*\/?$/ is a pattern that matches a URL. It consists of various components such as anchors, quantifiers, grouping constructs, bracket expressions, character classes, the OR operator, flags, and character escapes. This guide will provide a comprehensive explanation of each component used in the regex pattern.

Table of Contents