Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^((?:https?|ftp):\/\/?)?([^:/\s.]+\.[^:/\s]+|localhost)(:\d+)?((?:\/\w+)*\/)?([\w\-.]+[^#?\s]+)?([^#]*)?(#[\w-]*)?$
/
mg

Description

Validate URL and extracts its parts.

Submitted by anonymous - 6 years ago