我觉得你上面的第二个匹配的例子是不是打错了,感觉没有实际意义,下面写个一个正则,没匹配你第二个例子的需求,如果还是需要那种,我在改下
<script language=javascript>
    var str1='<IMG alt="" hspace=0 src="C:\\hx_web\\images\\down.gif" align=baseline border=0>'
    var str2='<IMG alt="" hspace=0 src="C:\\hx_web\\images\\down.gif" align=baseline border=0><IMG alt="" hspace=0 src="C:\\hx_web\\images\\up.gif" align=baseline border=0>'
    var str3='<P><IMG alt="" hspace=0 src="C:\\hx_web\\images\\down.gif" align=baseline border=0></P><P><IMG alt="" hspace=0 src="C:\\hx_web\\images\\up.gif" align=baseline border=0></P>'
    re=/([\"\'])([^"']+)(?:(\.gif)|(\.jpg))\1/ig
    alert(str1.match(re))//匹配1
    alert(str2.match(re))//匹配2
    alert(str3.match(re))//匹配3
</script>