Remove everything after last backslash

前端 未结 3 659
滥情空心
滥情空心 2021-02-02 05:41

var t = \"\\some\\route\\here\"

I need \"\\some\\route\" from it.

Thank you.

3条回答
  •  梦毁少年i
    2021-02-02 06:29

    Using JavaScript you can simply achieve this. Remove everything after last "_" occurance.

    var newResult = t.substring(0, t.lastIndexOf("_") );
    

提交回复
热议问题