TitleCasing a Sentence
return str.toLowerCase().replace(/^(\w)|(\s\w)/g, (L) => L.toUpperCase());
Here is a RegexChecker
- Identity the first letter of the sentence using
- Find all letters after a space
- combine them
I am gloating on the solution as I understand ReGex now a bit better thanks to FCC but I am not sure where this expression would fail in different examples for TitleCasing.
Wanted to know some opinions on it.