Created
July 6, 2018 04:53
-
-
Save renesansz/44c1e54d46ccad93b8fe1c3cb45ee44c to your computer and use it in GitHub Desktop.
JS Regex - Convert every first letter in a word to uppercase
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
var yourString = "davao city"; | |
var result = yourString.replace(/(^|\s)[a-z]/gm, c => c.toUpperCase()); | |
console.log(result); // Davao City |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment