🔡 Splits a string into an array of its words.
Syntax
import { words } from '@opentf/std';
words(
str: string,
pattern?: RegExp | string
): string[];Parameters
str: The string to split.pattern(Optional): The pattern to use for splitting.
Returns
An array of words.
Examples
words('fred, barney, & pebbles') //=> ['fred', 'barney', 'pebbles']
words('fred, barney, & pebbles', /[^, ]+/g) //=> ['fred', 'barney', '&', 'pebbles']