words
最后更新于:2022-04-02 00:07:58
## words
+ [link](./words "Link to this entry.")
+ [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L13063 "View in source.")
+ [npm](https://www.npmjs.com/package/lodash.words "See the npm package.")
```
_.words([string=''], [pattern])
```
拆分字符串中的词为数组
### 参数
1. [string=''] (string)
要处理的字符串
2. [pattern] (RegExp|string)
匹配模式
### 返回值 (Array)
然后拆分后的数组
### 示例
```
_.words('fred, barney, & pebbles');
// => ['fred', 'barney', 'pebbles']
_.words('fred, barney, & pebbles', /[^, ]+/g);
// => ['fred', 'barney', '&', 'pebbles']
```
';