1、  动态DOM创建

em = document.createElement("em");
em.innerHTML = Wallet.Game.getLabel(n) + ":";
span = document.createElement("code");
span.id = "span_" + n;
input = document.createElement("input");
input.type = "hidden";
input.id = n;

var xml = Wallet.Game.last_game_data, doc = xmldoc || xml.XMLDocument, text, node, val, tmpArr, str;
node = xml.selectSingleNode(doc, ".//" + n + "_list");
if (node) {
val = Wallet.getNodeValue(xml, node, "text()");
tmpArr = val.split(",");
Wallet.Game.recordset[n] = tmpArr;
node = xml.selectSingleNode(doc, ".//" + n + "name");
if (node) {
val = Wallet.getNodeValue(xml, node, "text()");
str = tmpArr[0] + val;
}else{
str = tmpArr[0];
}
//input.value = str
// output



input.setAttribute("value", str);
//output



text = document.createTextNode(str);
span.appendChild(text);
}
if(Wallet.Game.getHelpLink(n)){
span.innerHTML += Wallet.Game.getHelpLink(n);
}
span.appendChild(input);
p.appendChild(em);
p.appendChild(span);
if (!isReplace) {
o.appendChild(p);
}else {
var node = o.parentNode, pNode = node.parentNode;
pNode.replaceChild(p, node);
}

2、  正则表单式匹配,取分组值时的兼容,如果找不到对应的组时,IE9会输出undefined。其它为空串””。

var pattern = /^(\-?)(\d+)(\.\d+)?$/;var macher = pattern.exec(this);
var sign = null != macher ? RegExp.$1 : "";
var integer = null != macher ? RegExp.$2 : "0";
var decimal = null != macher ? RegExp.$3 : ".00";
 
//容错处理
var pattern = /^(\-?)(\d+)(\.\d+)?$/;
var macher = pattern.exec(this);
var sign = null != macher ? (RegExp.$1||"") : "";
var integer = null != macher ? (RegExp.$2||"0") : "0";
var decimal = null != macher ? (RegExp.$3||".00") : ".00";