const regex = /(https?:\/\/assets\.example\.com\/images\/[a-zA-Z0-9]{8,9})m(\/[a-zA-Z0-9]{8,9}\.jpg)/mg;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(https?:\\\/\\\/assets\\.example\\.com\\\/images\\\/[a-zA-Z0-9]{8,9})m(\\\/[a-zA-Z0-9]{8,9}\\.jpg)', 'mg')
const str = `http://assets.example.com/images/11233434m/23435436.jpg
http://assets.example.com/images/112aa3434m/23435436.jpg`;
const subst = `$1l$2`;
// 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