Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(?!.*[.]{2})((https?|http)\:\/\/)?([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?([a-z0-9-.-.]?(?!.*\/).*)\.([a-z]{2,1000})(\:[0-9]{2,5})?(\/([a-z0-9+\$_-]\.?)+)*\/?(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?
/
gm

Description

(?!.[.]{2})((https?|http)://)?([a-z0-9+!(),;?&=$.-]+(:[a-z0-9+!*(),;?&=$.-]+)?@)?([a-z0-9-.-.]?(?!./).).([a-z]{2,1000})(:[0-9]{2,5})?(/([a-z0-9+$-].?)+)*/?(?[a-z+&$.-][a-z0-9;:@&%=+/$.-]*)?(#[a-z.-][a-z0-9+$_.-]*)?

Submitted by Adwin Raj GP - 2 years ago