const regex = /{\s*["']\s*streamUrl\s*["']\s*:\s*["']\s*(http[^"']+)/gmi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('{\\s*["\']\\s*streamUrl\\s*["\']\\s*:\\s*["\']\\s*(http[^"\']+)', 'gmi')
const str = `"language":["Français"],"logo100x100":"http://static.radio.fr/images/broadcasts/15/43/8275/1/c100.png",
"streamUrls":[{"streamUrl":"http://mp3lg4.tdf-cdn.com/9243/lag_164753.mp3","loadbalanced":false,
"metaDataAvailable":false,"playingMode":"STEREO","type":"STREAM","sampleRate":44100,"streamContentFormat":"MP3",
"bitRate":128,"idBroadcast":8275,"sortOrder":0,"streamFormat":"ICECAST","id":47609,"streamStatus":"VALID",
"contentType":"audio/mpeg"},{"streamUrl":"http://mp3lg3.scdn.arkena.com/10490/virginradio.mp3","loadbalanced":false,
"metaDataAvailable":false,"playingMode":"STEREO","type":"STREAM","sampleRate":44100,"streamContentFormat":"MP3",
"bitRate":64,"idBroadcast":8275,"sortOrder":1,"streamFormat":"ICECAST","id":57003,"streamStatus":"VALID",
"contentType":"audio/mpeg"}],"playable":"PLAYABLE","genres":["Pop","Rock"],
"logo175x175":"http://static.radio.fr/images/broadcasts/15/43/8275/1/c175.png","
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions