[removed] Remove last character if a colon

后端 未结 3 1251
难免孤独
难免孤独 2021-02-02 05:41

Relative newcomer to Javascript and looking for a way to remove the last character of a string if it is a colon.

I know myString = myString.replace(\'/^\\\\:/\');<

3条回答
  •  情话喂你
    2021-02-02 05:51

    try simply with

    myString = myString.replace(/:$/, '');
    

    this will remove : when it is at the end of the string

提交回复
热议问题