Travis build: 688
This commit is contained in:
@ -5,10 +5,11 @@ Converts a string to title case.
|
||||
Break the string into words, using a regexp, and combine them capitalizing the first letter of each word and adding a whitespace between them.
|
||||
|
||||
```js
|
||||
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)
|
||||
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
||||
.join(' ');
|
||||
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)
|
||||
.map(x => x.charAt(0).toUpperCase() + x.slice(1))
|
||||
.join(' ');
|
||||
```
|
||||
|
||||
```js
|
||||
|
||||
Reference in New Issue
Block a user