/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/i
The purpose of this tutorial gist is to explain the regex for URL validation. This regex value demonstrates protocol optional URL validation.
The expression begins with a capture grouping expression. It searches for http in order, with an s as optional. It checks for a : and two //'s to make up https://. That entire part is wrapped in a capture group and is made optional by the ?.