从textarea中空格、逗号、换行转换为逗号分隔的字符串 js string.split



    // 空白(空格、换行、tab)和逗号分隔的字符串,变成用逗号分隔
    function getSplitString(str) {
        var arr = str.split(",");

        var resources = "";
        for (var i = 0; i < arr.length; i++) {
            var arr1 = arr[i].split(/\s+/);

            for (var j = 0; j < arr1.length; j++) {
                if (jQuery.trim(arr1[j]) != "") {
                    resources += jQuery.trim(arr1[j]) + ",";
                }
            }
        }

        return resources;
    }


你可能感兴趣的:(从textarea中空格、逗号、换行转换为逗号分隔的字符串 js string.split)