Javascript react native不支持RegExp?
我有一行代码:Javascript react native不支持RegExp?,javascript,regex,react-native,Javascript,Regex,React Native,我有一行代码: console.log("this is an example of test".match(new RegExp('.{0,3}am.{0,3}','gi'))); 如果我将其粘贴到控制台的chrome developer工具中,我会得到以下结果: [" example"] 但当我在react native中运行这行代码时,我得到 [ 'this is an example of test' ] 如何让react-native版本的regex给我输出[“示例”]?看起来像
console.log("this is an example of test".match(new RegExp('.{0,3}am.{0,3}','gi')));
如果我将其粘贴到控制台的chrome developer工具中,我会得到以下结果:
[" example"]
但当我在react native中运行这行代码时,我得到
[ 'this is an example of test' ]
如何让react-native版本的regex给我输出
[“示例”]
?看起来像react-native中正则表达式引擎中的一个bug
作为一种解决方法,您可以使用(.{0,3})am.{0,3}
,这似乎很有效