Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Created·2022-05-24 13:08
Flavor·PCRE2 (PHP)

/
^(([A-Za-z]{3,9}:(\/\/))([-;:&=\+\$,\w]+)[.]([-;:&=\+\$,\w]+)[.]([-;:&=\+\$,\w]+))(?:([.-;:&=\+\$,\w\/]*))$
/
gm
Open regex in editor

Description

Validates that all necessary parts of a "normal" domain are there (scheme, subdomain, secondary-level domain, top-level domain) and allows for additional subdirectories. Does not work for options like "mailto: example@email.com" or anything that does not stick to a typical web address URL.

Submitted by Alexa J.