主题
words
js
_.words([string=''], [pattern])将 string 拆分为其单词的数组。
¥Splits string into an array of its words.
新增于
¥Since
3.0.0
参数
¥Arguments
[string=''](字符串):要检查的字符串。¥
[string=''](string): The string to inspect.[pattern](正则表达式|字符串):要匹配单词的模式。¥
[pattern](RegExp|string): The pattern to match words.
返回
¥Returns
(数组):返回 string 的单词。
¥(Array): Returns the words of string.
示例
¥Example
js
_.words('fred, barney, & pebbles');
// => ['fred', 'barney', 'pebbles']
_.words('fred, barney, & pebbles', /[^, ]+/g);
// => ['fred', 'barney', '&', 'pebbles']