Replace first character of string

后端 未结 7 838
走了就别回头了
走了就别回头了 2020-12-05 23:01

I have a string |0|0|0|0

but it needs to be 0|0|0|0

How do I replace the first character (\'|\') with (\'\'

相关标签:
7条回答
  • 2020-12-05 23:55

    Try this:

    var str = "|0|0|0|0";
    str.replace(str.charAt(0), "");
    

    Avoid using substr() as it's considered deprecated.

    0 讨论(0)
提交回复
热议问题