remove everything before the last occurrence of a character

前端 未结 5 1326
执念已碎
执念已碎 2020-12-13 23:34

I\'m trying to perform the following action on a string :

  • find the last occurrence of the character \"/\";
  • remove everything before that
5条回答
  •  情话喂你
    2020-12-14 00:22

    var string = "/Roland/index.php";
    var result = string.substring(0, string.lastIndexOf("/") + 0);
    

提交回复
热议问题