@zzzzbov/split-into-words
v0.0.0
Published
`splitIntoWords` splits a string into an array of words, numbers, and individual punctuation marks. This is useful as a utility for transforming letter casing to various different formats.
Downloads
3
Readme
split-into-words
splitIntoWords
splits a string into an array of words, numbers, and individual punctuation marks. This is useful as a utility for transforming letter casing to various different formats.
"Words" are defined as runs of lowercase letters, uppercase letters, or a single uppercase letter followed by lowercase letters.
"Numbers" are defined as runs of digits.
All other characters (such as punctuation marks) will be split into individual entries in the resultant array.
Examples
| Example | Result |
| ----------------- | ----------------------------------- |
| "Hello, World!"
| ["Hello", ",", " ", "World", "!"]
|
| "camelCase"
| ["camel", "Case"]
|
| "PascalCase"
| ["Pascal", "Case"]
|
| "kebab-case"
| ["kebab", "-", "case"]
|
| "snake_case"
| ["snake", "_", "case"]
|
| "HTTPRequest"
| ["HTTP", "Request"]
|