Last active
November 21, 2017 22:15
-
-
Save RinatValiullov/57e1c5f7e2b5369626ee8212bacdff38 to your computer and use it in GitHub Desktop.
Add spaces in string and deleted first blank (with regular expressions)
This file contains 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
let addSpaces = (str) => { | |
str = str.replace(/([A-Z])/g, ' $1'); | |
let removeInitBlank = () => { | |
return str.replace(/^\s/, ''); | |
} | |
return removeInitBlank(); | |
}; | |
/* for example */ | |
addSpaces('ILoveJavascript!'); // I Love Javascript! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment