It is a little confusing exactly what you are asking. Perhaps if you give a few more examples or a sample of what code you have tried so far someone could be of more help.
Also, is the asterisk at the end of your input signifying something like a wildcard or is it just an asterisk?
As far as I can tell you are trying to do a variety of string intercolation.
var input= "/input1/input2/input3/input4*";
intercolateIntoPath(input);
--> "https://apple/input1/banana/input2/orange/input3/mango/input4*"
Here is fairly simple implementation of that functionality. There are others and even some much nicer syntax options in newer versions of Javascript (ES6) that isn’t supported on all browsers yet:
function intercolateIntoPath(input) {
var inputPieces= input.split("https://stackoverflow.com/");
var outputPieces = [
'https://apple', inputPieces[0], 'banana', inputPieces[1],
'orange', inputPieces[2], 'mango', inputPieces[3]
];
return outputPieces.join("https://stackoverflow.com/");
}
solved String manipulation – Javascript/JQuery [closed]