4
I need to get the string inside the last two bars (heDA6Yu7hsc) with javascript. How to proceed?
https://i.ytimg.com/vi/heDA6Yu7hsc/img.jpg
4
I need to get the string inside the last two bars (heDA6Yu7hsc) with javascript. How to proceed?
https://i.ytimg.com/vi/heDA6Yu7hsc/img.jpg
6
Try this way below:
var url="https://i.ytimg.com/vi/heDA6Yu7hsc/img.jpg";
var part = url.split("/");
console.log(part[4]);
Every part of array corresponds to a break of the split
[0]=https:
[1]=
[2]=i.ytimg.com
[3]=vi
[4]=heDA6Yu7hsc
[5]=img.jpg
2
You can also do by regular expression.
var texto = /\/([\w\d]+)\/[\w.]+$/gi.exec("https://i.ytimg.com/vi/heDA6Yu7hsc/img.jpg");
console.log(texto[1]);
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
Man, perfect. Thank you!!!!
– Thiago
^^, who good q helped
– Jasar Orion
does not forget to mark as solved
– Jasar Orion