Lodash _.words

2021-09-23 16:34 更新

_.words([string=''], [pattern]) 

拆分字符串string中的词为数组 。

添加版本

3.0.0

参数

  1. [string=''] (string): 要拆分的字符串。
  2. [pattern] (RegExp|string): 匹配模式。

返回

(Array): 返回拆分string后的数组。

例子

_.words('fred, barney, & pebbles');
// => ['fred', 'barney', 'pebbles'] 
_.words('fred, barney, & pebbles', /[^, ]+/g);
// => ['fred', 'barney', '&', 'pebbles']


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号