You can do this in a very simple way, using a regular expression to pick up the two numbers from the last bar /
, the first number being the value of "idManga" and the second the value of "idCapitulo".
Using url.substr(url.lastIndexOf("/"))
will return everything you have from the last bar forward, ie:
/?idManga=1&idCapitulo=2
Then just use a .match()
with the regular expression /\d+/g
which will return an array with the two values:
["1", "2"]
The expression /\d+/g
takes anything that is number in the string, creating the array by separating the values in each index, where the index [0]
is the value of "idManga" and the index [1]
the value of "idCapitulo".
See how it looks:
let url = "https://localhost:44380/Manga/MangaPaginas/?idManga=10&idCapitulo=21";
const valores = url.substr(url.lastIndexOf("/")).match(/\d+/g);
console.log("idManga = ", valores[0]);
console.log("idCapitulo = ", valores[1]);
Do you want to pick up where? No backend? No frontend? How are these values coming?
– Felipe Avelar
i’m already picking up this value, I want to filter by javascript.
– igor3k
this Odigo is running on the html page
– igor3k
this string is fixed, I just need to extract the two numbers
– igor3k