const regex = /.*(https)*\/(.*)\.(.*\?|.*$)(.*$)/mg;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('.*(https)*\\\/(.*)\\.(.*\\?|.*$)(.*$)', 'mg')
const str = `https://dso.nr.ncia/qa/ivva/_layouts/15/listform.aspx
https://dso.nr.ncia/qa/ivva/_layouts/15/listform.aspx?PageType=6&ListId=%7BD1F613C9%2DA0B4%2D4219%2D9445%2D0BA09B3A43B2%7D&ID=409
https://dso.nr.ncia/qa/ivva/_layouts/15/listform.aspx?PageType=4&ListId=86f2f400-e5e8-4afd-bced-1230c88104b0&ID=13&RootFolder=*
https://dso.nr.ncia/qa/ivva/Lists/ServiceAssuranceMatrix1/Lionel.aspx
`;
const subst = `$2.$3 `;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
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