Webflags: gi

URL Validation

Match http and https URLs with optional www prefix, paths, query strings, and fragments.

Try it in RegexPro

Pattern

regexJavaScript
/https?:\/\/(?:www\.)?[\w\-]+(?:\.[\w\-]+)+[\w\-._~:/?#\[\]@!$&'()*+,;=%]*/gi

Raw source: https?:\/\/(?:www\.)?[\w\-]+(?:\.[\w\-]+)+[\w\-._~:/?#\[\]@!$&'()*+,;=%]*

How it works

Starts with http:// or https://, optional www., then one or more domain labels separated by dots, followed by any valid URL characters for the path and query.

Examples

Input

https://www.example.com

Matches

  • https://www.example.com

Input

http://api.example.org/v1/users?id=42

Matches

  • http://api.example.org/v1/users?id=42

Input

not a url

No match

Common use cases

  • Extracting links from text or HTML
  • Validating user-submitted URLs
  • Web scraping and crawling
  • Security scanning for external links
All patternsTest this pattern live →