Update snippets/toTitleCase.md
Co-Authored-By: ccjmne <ccjmne@gmail.com>
This commit is contained in:
@ -7,7 +7,7 @@ Break the string into words, using a regexp, and combine them capitalizing the f
|
|||||||
```js
|
```js
|
||||||
const toTitleCase = str => str
|
const toTitleCase = str => str
|
||||||
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
||||||
.map(x => x.charAt(0).toUpperCase() + x.slice(1).toLowerCase())
|
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
||||||
.join(' ');
|
.join(' ');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user