words

String
since 3.0.0

Arguments

  • string The string to inspect.
  • RegExp|string The pattern to match words.

Returns

Array the words of `string`.

Splits string into an array of its words.

Example of Lodash _.words

_.words('fred, barney, & pebbles');
// => ['fred', 'barney', 'pebbles']

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