js截取指定字符前面或后面的内容

getCaption(obj, state,strname) {
            var index = obj.lastIndexOf(strname);
            if (state == 0) {
                obj = obj.substring(0, index);
            } else {
                obj = obj.substring(index + 1, obj.length);
            }
            return obj;
        }

//调用

getCaption('abcefefef/9jccdmcdcmdm',1,"/9j")    //9jccdmcdcmdm
posted @ 2023-02-09 14:10  abcByme  阅读(329)  评论(0编辑  收藏  举报