Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
(https?:\/\/)((?:[-a-zA-Z0-9@:%._+~#=]+)\.)?([-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b|localhost(?:\:\d{1,5})?)(\/[\w.-]*)*(\?[\w\-._~!*'(),%=&+]*)?($|\#.*|\?.*)?
/
gm

Description

Match a URL and capture its parts. Please suggest your improvements.

Submitted by Lamer217 - 9 months ago