Regular Expressions 101

Community Patterns

1...34567...881

URL

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 - 3 months ago