Regular Expressions 101

Community Patterns

Community Library Entry

2

Regular Expression
PCRE (PHP <7.3)

/
(http:\/\/\s*|https:\/\/\s*|ftp:\/\/\s*)?(www\s*)?(?(1)([.]\s*))?(?(2)([.]\s*))?([a-zA-Z0-9.-]{2,256})(\s*[.]\s*)(ru|pl|kz|by|ua|com|in|pt|br|co.uk)(?![a-zA-Z])([?|#]{1}[=&#a-zA-Z0-9]{2,128})?
/
gui

Description

Sim regexp to try to catch a URL or a obfuscated URL (with spaces) from a string

Submitted by Eduardo Pereira - 8 years ago