当前位置:编程学习 > JS >>

js中清除字符串中某个字符串

#create ydds
#date 2009-09-20
//remove src target
function removeStrWithcomma(srcStr, targetStr){
    var returnStr = '';
    if (srcStr == null || srcStr == '' || srcStr == undefined) {
        return returnStr;
    }
    else
        if (srcStr.indexOf(targetStr) == -1) {
            return srcStr;
        }
        else {
            var srcStrs = srcStr.split(',');
            if (srcStrs.length == 1) {
                returnStr = '';
            }
            else
                if (srcStr.match(eval("/^" + targetStr + ".*/")) != null) {
                    returnStr = srcStr.replace(targetStr + ',', '');
                }
                else
                    if (srcStr.match(eval("/.*" + targetStr + "$/")) != null) {
                        returnStr = srcStr.replace(',' + targetStr, '');
                    }
                    else {
                        returnStr = srcStr.replace(',' + targetStr, '');
                    }
            return returnStr;
        }
}
var xmlHttplink;
function createXMLLinkHttpRequest(){
    if (window.ActiveXObject) {
        xmlHttplink = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else
        if (window.XMLHttpRequest) {
            xmlHttplink = new XMLHttpRequest();
        }
}
本文出自 “一灯” 博客

补充:Web开发 , Jsp ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,