var stringVal = "../folder1/folder2/image1.jpg";
stringVal = stringVal.replace(/[../]/g , "");
It will replace all / of string, but I want just replace ../.
How can do that?
You can use regex \.{2}\/

[../]is acharacter classthat meansany character from . or /
var stringVal = "../folder1/folder2/image1.jpg";
stringVal = stringVal.replace(/\.{2}\//g, "");
document.write(stringVal);
You could do it this way if you don't want to get into the regex stuff.
stringVal.split("../").join("")
otherwise you'll need to escape the control characters in your regular expression. Here's another answer that should help: Replacing all occurrences of a string in JavaScript