_.words(拆分字符串为数组)
语法:
_.words([string=''], [pattern])
源代码链接:source
npm包链接:npm package
描述:
拆分字符串string
中的词为数组 。
开始版本:3.0.0
参数:
[string=''] (string)
: 要拆分的字符串。[pattern] (RegExp|string)
: 匹配模式。
返回值:
(Array)
: 返回拆分string后的数组。
例子:
_.words('fred, barney, & pebbles');
// => ['fred', 'barney', 'pebbles']
_.words('fred, barney, & pebbles', /[^, ]+/g);
// => ['fred', 'barney', '&', 'pebbles']
Last updated
Was this helpful?