ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 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'] ```