Created
August 1, 2019 13:41
-
-
Save icodesido/c437cadca8377993383bf2373e985919 to your computer and use it in GitHub Desktop.
Lookaheads in RegExp
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
const toSpinal = str => str.split(/\s|_|(?=[A-Z])/).join('-').toLowerCase() | |
console.log(toSpinal("I like potatoes")) //i-like-potatoes | |
console.log(toSpinal("ILikeCarrots")) //i-like-carrots | |
console.log(toSpinal("ThisIsA_really We1rdString")) //this-is-a-really-we1rd-string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment