Formatting URLs in the old Regex Interface

This page is for formatting regexes using an older interface. It will have a single field for the regex, not the 3-field version with subdomain, tld and path.


Since some URLs start with http, and others with https, and some of your visitors may have a browser extension that automatically turns all http URLs into https ones, it's occasionally very important to include both options within your regex. Here's how you would do that:


The ? after the "s" means that there can be 0 or 1 "s" - meaning http and https are both included. The question mark only affects the ONE character in behind it, unless you put them inside parentheses, as you'll see in just a moment. Put this together with the escaped-slash we learned earlier, and you get:


The \/\/ pattern is the two // with escape slashes. A single slash would look like \/, and an optional slash would look like \/?

We don't need to escape the : because it's not a special character.

To include the "www." you would include the following part:


The parentheses around the "www." mean (everything in here) - just like in Algebra class. We still have to escape the . and we add the ? at the end to show that it's not required, that there can be 0 or 1 "www."

Putting the Pieces Together

If the site we are using is, our whole regex targeting it would look like:


This will match:

Note that these URLs include all the combinations of http, https, www or no www, and the final /

The Beginning and The End

In this older interface, we also need to tell the regex where to stop and end. This is done by using two other special characters, ^ and $. The ^ marks the beginning of the regex, and the $ marks the end. Using the example from above, this would be your regex:


To use this example, you would add the following to your regex field:



Back to the beginning (Introduction)

Have more questions? Submit a request
Powered by Zendesk