const regex = /(https:\/\/provider\.shsp\.swisscom\.com(?:(?!(:443|:80)(\/|\s))(?:(?::)(\d*)))*(?!:443|:80))+((?!\/stable(?=\/))(\/latest(?=\/))?)*/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(https:\\\/\\\/provider\\.shsp\\.swisscom\\.com(?:(?!(:443|:80)(\\\/|\\s))(?:(?::)(\\d*)))*(?!:443|:80))+((?!\\\/stable(?=\\\/))(\\\/latest(?=\\\/))?)*', 'g')
const str = `({"repository":"https://company.swisscom.local","remoteAppUrl":"https://provider.shsp.swisscom.com/","clientId":"eb922115-1e2d-4aa6-b79e-e0a02719d0ad","appWebUrl":"","subscriptionId":"ccf5cd8e-0a6b-4cca-8e3d-1576c4a23ae1","tenantId":"f486778e-3f8a-4d65-9864-3762839c950e","version":"1.61.0","isWorkspaceWebApplication":false,"workspaceRepository":"https://company.swisscom.local","providerInstance":"latest","adfsLogOutUrl":null},["https://provider.shsp.swisscom.com:443/latest/scripts/init/{lcid}/SCI.js?rev=279634fa70164cc4b9465e46146ead7f"],"https://cdn.shsp.azureedgnet.net/scripts/sharespace.js?v=1.61.0");`;
// 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