Skip to content

words

拆分字符串为单词数组。

示例

ts
import { words } from '@base-web-kits/base-tools-ts';

words('fred, barney, & pebbles');
// 结果: ['fred', 'barney', 'pebbles']

参数

  • string (string): 要拆分的字符串。
  • pattern (RegExp|string): 匹配模式。

返回值

  • (Array): 返回单词数组。

来源