const regex = /(.+)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(.+)', 'gm')
const str = `s01e01
s01e02
s01e03
s01e05
s01e06
s01e07
s01e08
s01e10
s01e11
s01e12
s01e14
s01e15
s02e02
s02e03
s02e04
s02e05
s02e07
s03e01
s03e05
s04e01
s04e02
s04e04
s04e05
s04e06
`;
const subst = `move \1\\*.* . && rd \1`;
// 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