//替换脚本字符
function htmlLableExe(resultvalue) {
var regExp = new RegExp(/[<>&]+/g);
var newValue = "";
if (regExp.test(resultvalue)) {
for (var i = 0; i < resultvalue.length; i++) {
var strValue = resultvalue.charAt(i);
if (strValue == "<") {
newValue += strValue.replace(/[<]+/g, "<");
} else if (strValue == ">") {
newValue += strValue.replace(/[>]+/g, ">")
} else if (strValue == "&") {
newValue += strValue.replace(/[&]+/g, "&");
} else {
newValue += strValue;
}
}
return newValue;
} else {
return resultvalue;
}
}
//替换特殊字符
function encodeWordURI(tplan) {
tplan = encodeURI(tplan); //已把%号转为%25
tplan = tplan.replace(/\+/g, "%2B");
tplan = tplan.replace(/\ /g, "%20");
tplan = tplan.replace(/\//g, "%2F");
tplan = tplan.replace(/\#/g, "%23");
tplan = tplan.replace(/\&/g, "%26");
tplan = tplan.replace(/\=/g, "%3D");
tplan = tplan.replace(/\?/g, "%3F");
return tplan;
}
//替换空格
$("#test").val(function(index, value) {
return value.replace(/[\r\n]+/g, " ");;
});