Regular Expressions 101

Community Patterns

Local url detection

2

Regular Expression
PCRE (PHP <7.3)

/
((?:(?:https?):\/\/)?(?:regex101\.com|www\.regex101\.com|regex101\.com|(?<![:\/])\/)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|])
/
g

Description

Detect if an url is local (even if written in an absolute way)

Submitted by Jean Fenouil - 8 years ago