更新时间:2023-02-18 16:55:11
String.prototype.replaceAll =功能(目标,更换){
返回this.split(目标)。加入(更换);
};
阵列=新的Array(A1 / A2 / A3)对于(i = 0; I< array.length ++我){
数组[我] =阵列[I] .replaceAll(/,,)
}
这是否帮助?
How can I replace ',' with a '/' in an array list using javascript. Here my array-list has two string 'values separated by a comma ',' but I want to make it in form of a single string separating the values by '/' ?
For eg : array[] = { value1, a1/a2/a3}
to be replaced by array[] = {value1/a1/a2/a3}
For example: Here I want to replace the outcome which comes as [3,101/102/103]
by [3/101/102/103].
Can anyone please suggest ?
String.prototype.replaceAll = function(target, replacement) {
return this.split(target).join(replacement);
};
array = new Array("a1/a2/a3")
for (i = 0; i < array.length; ++i) {
array[i] = array[i].replaceAll("/",",")
}
does this help?