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