Regular Expressions 101

Community Patterns

catch or match URL or URI

1

Regular Expression
PCRE (PHP <7.3)

/
(?(DEFINE) (?<protocol> (?<=^|[^a-z]) [a-z]+? : ) (?<domain> (?:[a-z\-]+\.)+[a-z\-]+ ) (?<ip> (?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?) ) (?<port> (?<!\s):\d+(?=\/|$|\s)) (?<pathquery>[A-Za-z\d\!\*\(\)\;\:\@\&\=\+\$\,\/\?\#\[\]\%\{\}\|\\\^\`\~]+) (?<url> (?&protocol) (?: (?:\/\/) (?: (?&domain) | (?&ip) ) (?&port)? )? (?&pathquery)) ) (?&url)
/
uxmg

Description

any more? tell me by email.

Submitted by CSnowstar(997596@gmail.com) - 9 years ago