Regex expressions are not easy to decipher. What is that? The first time you see one, you may think, "Hey, someone's keyboard is broken, look at this alien code". Well, it happens that it is a very clever code, actually. In just one Regex line you have a complete set of instructions to evaluate whether a user's input follows a pattern or not. In this tutorial, we will clearly, concisely, and undoubtedly explain how a regular expression checks a URL pattern. :-)
The first half of this tutorial contains an explanation of all the parts that make a regex, and how they work together. The second half is a real example of a regular expression that checks how a URL string matches a regex pattern. In this tutorial we will use the following regex literal:
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/