i have this string => someRandomText&ab_channel=thisPartCanChange and i want to delete all from & (inclusive) to the end [this part: &ab_channel=thisPartCanChange].
How can i do this?
You van try something like:
console.log("someRandomText&ab_channel=thisPartCanChange".split("&")[0])
const yourString = 'SomeRandomText&ab_channel=thisPartCanChange'
console.log(yourString.split('&ab_channel')[0])
I would do a regex replacement on &.*$ and replace with empty string.
var inputs = ["someRandomText&ab_channel=thisPartCanChange", "someRandomText"];
inputs.forEach(x => console.log(x.replace(/&.*$/, "")));
Note that the above approach is robust with regard to strings which don't even have a & component.