How to globally replace a forward slash in a JavaScript string?

后端 未结 10 2069
逝去的感伤
逝去的感伤 2020-11-28 22:05

How to globally replace a forward slash in a JavaScript string?

10条回答
  •  孤独总比滥情好
    2020-11-28 22:58

    Hi a small correction in the above script.. above script skipping the first character when displaying the output.

    function stripSlashes(x)
    {
    var y = "";
    for(i = 0; i < x.length; i++)
    {
        if(x.charAt(i) == "/")
        {
            y += "";
        }
        else
        {
            y+= x.charAt(i);
        }
    }
    return y;   
    }
    

提交回复
热议问题