Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript react native不支持RegExp?_Javascript_Regex_React Native - Fatal编程技术网

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}
,这似乎很有效