Skip to content

Instantly share code, notes, and snippets.

@dillon
Last active January 6, 2021 19:01
Show Gist options
  • Save dillon/e238f2bc62667257da476ca680c7ebfb to your computer and use it in GitHub Desktop.
Save dillon/e238f2bc62667257da476ca680c7ebfb to your computer and use it in GitHub Desktop.

Regex for internal slug:

^[a-z0-9]+(?:-[a-z0-9]+)*$

Regex for external URL:

^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-/]))?$

Regex for external OR internal slug:

^((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)|(\/[a-z0-9]*(?:-[a-z0-9]+)*)$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment