RegEx - Get All Characters After Last Slash in URL

后端 未结 8 2171
无人共我
无人共我 2020-11-29 07:00

I\'m working with a Google API that returns IDs in the below format, which I\'ve saved as a string. How can I write a Regular Expression in javascript to trim the string to

8条回答
  •  执笔经年
    2020-11-29 07:31

    this regexp: [^\/]+$ - works like a champ:

    var id = ".../base/nabb80191e23b7d9"
    
    result = id.match(/[^\/]+$/)[0];
    
    // results -> "nabb80191e23b7d9"
    

提交回复
热议问题