words

Split a string into an array of words, recognizing camelCase, snake_case, and kebab-case boundaries for reliable tokenization.

Usage

words is the foundation for all case-conversion functions. It accepts a string and splits it into an array of words. It handles camelCase, snake_case, kebab-case, and abbreviations.

import { words } from '@movk/core'

words('helloWorld') // => ['hello', 'World']
words('hello_world') // => ['hello', 'world']
words('hello-world') // => ['hello', 'world']
words('XMLHttpRequest') // => ['XML', 'Http', 'Request']

API

words(str: string): string[]

Parameters

str
string required
The string to split.

Returns

string[]
Returns an array of words extracted from the input string.

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License