Having a string such like this one:
var str = "https://www.portalinmobiliario.com/venta/departamento/vitacura-metropolitana/6579-parque-arboleda-nva";
I need to be able to only get "6579" number from that string, because it is an ID I need to use. In fact, this ID is always located between that last "/" and the next "-" that follows.
So considering that the url is dynamic but this "ID" is always between these two characters "/" and "-", I have to be able to always get the ID.
Any Idea how could I solve this?
I tried with this but
var id = str.lastIndexOf('/');