Created
January 11, 2019 06:52
-
-
Save sujeetkv/6eef8416e7ee98475f55378f266dd9ca to your computer and use it in GitHub Desktop.
Slug Regex Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* (?!_) 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