Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.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
Internet Explorer中的Javascript正则表达式问题_Javascript_Regex - Fatal编程技术网

Internet Explorer中的Javascript正则表达式问题

Internet Explorer中的Javascript正则表达式问题,javascript,regex,Javascript,Regex,我正在尝试使用正则表达式拆分Javascript中的字符串。我的代码如下: var status = "This is a test http://yfrog.com/5y6eruj"; var regexp = /(http:\/\/yfrog\.com(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; matchParts = status.split(regexp); alert(match

我正在尝试使用正则表达式拆分Javascript中的字符串。我的代码如下:

var status = "This is a test http://yfrog.com/5y6eruj";    
var regexp = /(http:\/\/yfrog\.com(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;  
matchParts = status.split(regexp);
alert(matchParts);
在Chrome和FF中,当我提醒
matchParts
时,它是一个数组,包含文本,然后是url。然而在IE中,
matchParts
只是文本,url已经消失了

要么IE中有一个奇怪的bug,要么我的正则表达式不太正确……请帮助

我不会使用“拆分”来进行此操作,因为它有缺陷:

试一试

相反。您可能需要稍微修改一下正则表达式(我将尝试并更新)

编辑如果将
(.*)
添加到正则表达式的开头,也将拾取前导文本

var matchParts = regexp.exec(status);