words

Splits the str into an array of words, supporting various case styles and delimiters.

Usage Scenarios

  • Text Analysis: In natural language processing, split text into words for analysis.
  • Data Parsing: Parse strings into words for further processing.

Example

import { words } from 'funtool/string'

words('helloWorld'); // ✅ ['hello', 'World']
words('HelloWorld'); // ✅ ['Hello', 'World']
words('hello_world'); // ✅ ['hello', 'world']
words('APIversion'); // ✅ ['API', 'version']
words('userID2Token'); // ✅ ['user', 'ID', '2', 'Token']
words('HTMLBody'); // ✅ ['HTML', 'Body']
words('APIResponse'); // ✅ ['API', 'Response']

Signature

function words(str: string): string[]

Parameters

  • str ( string ): The input string.

Returns

  • ( string[] ): An array of words extracted from the string.