Options
All
  • Public
  • Public/Protected
  • All
Menu

Module words

Index

References

Functions String

References

Renames and re-exports __type

String Functions

  • words(string: string, pattern?: string | RegExp): string[]
  • Splits string into an array of its words.

    since

    5.12.0

    example
    words('fred, barney, & pebbles')
    // => ['fred', 'barney', 'pebbles']

    words('fred, barney, & pebbles', /[^, ]+/g)
    // => ['fred', 'barney', '&', 'pebbles']

    Parameters

    • string: string

      The string to inspect.

    • pattern: string | RegExp = undefined

      The pattern to match words.

    Returns string[]

    Returns the words of string.