This tutorial explains how to use a regex to match a url.
This breaks down the regular expression(regex) that matches a URL.
Refer to the reference below on what the various operators mean.
Here is a breakdown of the matching URL regex:
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/