There is such code:

let parsedUrl = new URL("https://streamguard.cc/serial/412c6a4100be1a0f41a4c57b00c2d57d/iframe?season=1&nocontrols=1&episode=366?origin=yummyanime.com"); // ?...?... console.log(parsedUrl.searchParams.get("episode") ); // wparam="366?origin=yummyanime.com" TODO: param="366" 

I get the URL through window.location.href, and at the top of the URL as an example.

How to do without the split method?

parsedUrl.searchParams.get("episode").split("?"); // Array [ "366", "origin=yummyanime.com" ];

I think it would be wrong to break it this way and probably need to separate the lines before the get method. Ideally, the result of such a "parsed URL" would be written to an array.

// Array [ "season=1&nocontrols=1&episode=366", "origin=yummyanime.com" ]

Support for MS browsers is not needed.

After some time, I wrote this:

 let parsedUrl = new URL(window.location.href); parsedUrl.href.split("?").map(function(echo){ return new URLSearchParams(echo).get("episode"); });//Array [ null, "366", null ] 

Will such a decision? Maybe there is a more elegant and clear solution? I apologize for the style of the former with ++ 'shnik :) I would only be on pure JS , if possible, and the output is "s = 1 & e = 366".

With url.match (/ episode = (\ d +) /) [1], you will need to use the try..catch construction.


A pair of //Array["1","366"] fit in, as a result, it is planned to write to the database. Or you can get the output in the format string "s =" + data + "& e =" + data ("s = 1 & e = 366").

  • one
    As a result, it is not clear what you want to receive. Data from get? divided as a key value or in pairs in an array or something like that .. output what? - Alexey Shimansky
  • nothing is clear, but it seems necessary to find an episode ... with such an url it’s probably easier to portray something like url.match (/ episode = (\ d +) /) [1] - MedvedevDev
  • Messages must be edited from your account, not from an anonymous one. - Qwertiy
  • If you need to get par, then window.location.search to help. And why is "using split" wrong? - Michael
  • Link tyrk Choose where more votes, then Ctrl + C - Stanislav Sagan

0