Skip to content

Instantly share code, notes, and snippets.

@zhasm
Created December 24, 2013 10:35
Show Gist options
  • Save zhasm/8111447 to your computer and use it in GitHub Desktop.
Save zhasm/8111447 to your computer and use it in GitHub Desktop.
url regex.
const URL_REGEXP_PROTOCOL = '(?:(http|https):\/\/)';
const URL_REGEXP_USER = '(?:[^\/]+?(?::[^\/]+?)?@)?';
const URL_REGEXP_HOST = '(?:(?:(www\.)?(?:[\w\-]+\.)+(?:[a-z]{2,4}))|(?:(?:\d{1,3}\.){3}\d{1,3}))';
const URL_REGEXP_PORT = '(?::\d{1,5})';
const URL_REGEXP_QUERY = '(?:\/[\w\-\?\.\=\&\+\%\[\]\/#;@:~!]*)';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment