Skip to content

Instantly share code, notes, and snippets.

@sujeetkv
Created January 11, 2019 06:52
Show Gist options
  • Save sujeetkv/6eef8416e7ee98475f55378f266dd9ca to your computer and use it in GitHub Desktop.
Save sujeetkv/6eef8416e7ee98475f55378f266dd9ca to your computer and use it in GitHub Desktop.
Slug Regex Example
/**
* (?!_) can not start with seperator
* (?!.*?_$) can not start with seperator
* [a-z] first letter should be alphabet
* [a-z_]+ other slug string
*
* @see https://unix.stackexchange.com/questions/78481/regex-to-match-identifiers-without-double
*/
var regex = /^(?!_)(?!.*?_$)[a-z][a-z_]+$/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment