words
Splits a string into an array of words.
null and undefined return [].
Handles camelCase, PascalCase, SCREAMING_SNAKE_CASE, kebab-case, snake_case, and regular whitespace-separated text. Numbers are treated as word tokens.
Available since v2.0.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
str | string | null | undefined | The string to split into words. |
Returns
Section titled “Returns”string[] — An array of word tokens.
Examples
Section titled “Examples”Split common string formats
Section titled “Split common string formats”Splits camelCase, PascalCase, snake_case, kebab-case and space-separated words.
Build camelCase from any input
Section titled “Build camelCase from any input”Combine with a map to convert from any naming convention.
