首页 > 解决方案 > Node.js 是否支持 String.MatchAll 方法?

问题描述

当我测试代码时:

let result = 'heymama'.matchAll(/m(a)/g);

我收到错误“ 'heymama'.matchAll 不是函数

当我运行版本时:

let result = 'heymama'.match(/ma/g);

没有错误。

标签: node.jsregex

解决方案


matchAll从 v12.0.0 开始在 Node.js 中可用


推荐阅读