I have a string that looks like this:
const string = 'test_string%name=peter&age=18&foo=bar&lol=loli_copter';
I want to write a regex to get name
and the age
from this string and their values.
const result = 'name=peter&age=18;
I have tried the following but with no luck:
const result = string.match(/(?<=name\s+).*?(?=\s+age)/gs);
Can anyone help or point me in the right direction?