---
title: "words"
description: "Split a string into an array of words, recognizing camelCase, snake_case, and kebab-case boundaries for reliable tokenization."
canonical_url: "https://core.mhaibaraai.cn/en/docs/transformers/string/words"
---
# 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.

```ts
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

See commit history for [src/transformers/string/words.ts](https://github.com/mhaibaraai/movk-core/commits/main/src/transformers/string/words.ts).

---

- [GitHub](https://github.com/mhaibaraai/movk-core/blob/main/src/transformers/string/words.ts)


## Sitemap

See the full [sitemap](https://core.mhaibaraai.cn/sitemap.md) for all pages.
