唉 好久碰正则了, 请教一下
km[123]=new Array( "? ", "? ");
km[124]=new Array( "? ", "? ");
。。。。。
怎么用正则提取出字符串中的:
123 ? ?
124 ?? ??
....
------解决方案--------------------var regexp = /km\[(\d+)\]=\s*new\s*Array\( "([^ "]+) "\);/g;
记得不要加 "i "选项哦...
------解决方案-------------------- <script language=javascript>
function RegexTest(yourStr)
{
return /\w+\[\d+\] ?= ?new Array\(\ "[^\ "]*\ ",\ "[^\ "]*\ "\);/.exec(yourStr);
}
alert(RegexTest( "km[123]=new Array(\ "?\ ",\ "?\ "); "));
</script>