JavaScript indexOf() - how to get specific index

前端 未结 8 589
野趣味
野趣味 2021-01-18 02:02

Let\'s say I have a URL:

http://something.com/somethingheretoo

and I want to get what\'s after the 3rd instance of /?

8条回答
  •  遥遥无期
    2021-01-18 02:42

    In your case, you could use the lastIndexOf() method to get the 3rd forward slash.

提交回复
热议问题