change the URL path one folder before in javascript string : my url look like below. i need to move one folder before for reference. i can you regex. I have also tried several things. bot nothing works for me.

    var str = "../../myfolder";
    var str0 = "../myfolder";
    var str1 = "../../../myfolder";

i need to change this as

    str = "../myfolder";
    str0 = "myfolder";
    str1 = "../../myfolder";

please help me for this. 