const regex = /^(\s*(?:Su|M|Tu|W|Th|F|S|R))((?:Su|M|Tu|W|Th|F|S|R){1,2})(.*)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(\\s*(?:Su|M|Tu|W|Th|F|S|R))((?:Su|M|Tu|W|Th|F|S|R){1,2})(.*)', 'gm')
const str = `WRF 9a-5p
WR 9-10:15a
WR 7:15-8:45p
WF 9a-12:10p
WF 9:30-11:30a
WF 8-10:45a
WF 12-2:45p
Su 9a-6p
WF 10-11:50a
W 9a-12p
W 9a-12p
W 9a-12:20p
W 9a-12:20p
W 9a-12:20p
W 9:30a-4:45p`;
const subst = `$1$3\n$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