Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
ECMAScript (JavaScript)

/
^(?:https?:\/\/)?([-\w.]+\.[\w]+){1}(\/[\/\d\w\.\-\?\+\&\#\=\~]*)?$
/
gi

Description

This regex is used to extract a domain name (including subdomains) and the full URI from a URL. will not match when credentials are provided in the url.

Submitted by anonymous - 2 years ago