Write a free-space regular expression in Regex101, paste it in the top box, and the bottom box will compile it. Put the compiled regex in your code, and the free-space source in your comments.


What's this?

This tool lets you write regexes that look like this:

  # When using http://, allow any domain
  https?:\/\/ [a-z0-9-]+ ( \. [a-z0-9-]+ )*
  # When using www., expect at least one more dot
  www \. [a-z0-9-]+ ( \. [a-z0-9-]+ )+
  # Otherwise, allow any domain, but only if
  [a-z0-9-]+ ( \. [a-z0-9-]+ )* \.
    # followed either a common TLD...
    com? | org | net | edu | info | us | jp
    # or any 2-3 letter TLD followed by : or /
    [a-z]{2,3} (?=[:\/])

Instead of this:


It's called a free-space regular expression: it ignores whitespace, so you can line-break and indent it however you want. To actually search for a space, use . You can also add comments starting with #.

This lets you use XRegExp without the performance impact.