How to choose a substring after given character

后端 未结 4 873
我寻月下人不归
我寻月下人不归 2021-01-18 18:12

I would like to save a substring to a javascript variable using regex unless there is a different/easier way. For example i have a link like this: http://www.youtube.com/wa

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-18 18:38

    not with regex, but simple too, because first url part is static and has 23 symbols length

    'http://www.youtube.com/watch?v=sEHN4t29oXY&feature=related'.substr(23)
    

    Oh, I've made a mistake, he wants another part, so actual code will looks like:

    'http://www.youtube.com/watch?v=sEHN4t29oXY&feature=related'.substr(31)
    

提交回复
热议问题