Closed GoogleCodeExporter closed 8 years ago
Builder.prototype.getText = function(node) {
var txt = null;
if (getNodeType(node) == constants.ELEMENT_TYPE_NODE) {
if (node.childNodes.length > 0) {
for (var i = 0; i < node.childNodes.length; i++) {
if (node.childNodes[i].nodeType == Node.TEXT_NODE) {
txt = node.childNodes[i].nodeValue;
if (txt != null) {
//test if the regular expression includes "
var regexp = new RegExp(/\"/);
if(regexp.test(txt)){
//if we do have double quota " inside
//throw away the text attribute because if it is way too difficult to escape
txt = null;
}else{
txt = this.getTextReg(txt);
}
}
break;
}
}
}
}
return txt;
};
Builder.prototype.getTextReg = function(txt) {
var text = txt.replace(/^ *(.*?) *$/, "$1");
if (text.match(/\xA0/)) { // if the text contains
return "regexp:" + text.replace(/[\(\)\[\]\\\^\$\*\+\?\.\|\{\}]/g, function(str) {return '\\' + str})
.replace(/\s+/g, function(str) {
if (str.match(/\xA0/)) {
if (str.length > 1) {
return "\\s+";
} else {
return "\\s";
}
} else {
return str;
}
});
} else {
return text;
}
};
Original comment by John.Jian.Fang@gmail.com
on 14 Aug 2010 at 3:53
Original issue reported on code.google.com by
John.Jian.Fang@gmail.com
on 8 Aug 2010 at 5:22