const regex = /SSR.(....)(.BE.)(\w+)(-1)(\w+)(\/)(\w+).*/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('SSR.(....)(.BE.)(\\w+)(-1)(\\w+)(\\\/)(\\w+).*', 'gm')
const str = `SSR BAGW BE HK1DUBEXT0304H13OCT-1TIMBRELL/TEGAELAMISS.1P/AUTH 23KG
SSR BAGA BE HK1DUBLON0301H13NOV-1TIMBRELL/TEGAELAMISS.1P/AUTH 23KG
SSR DOCS BE HK1DUBEXT0204H13DEC-1TIMBRELL/TEGAELAMISS
SSR PETC BE HK1LONEXT0334H13JAN-1TIMBRELL/TEGAELAMISS
SSR WCHR BE HK1DUBEXT0204H13DEC-1TIMBRELL/TEGAELAMISS
SSR BAGW BE HK1DUBLON0301H13NOV-1TIMBRELL/TEGAELAMISS.1P/AUTH 23KG
BE7351 H 08NOV18MANMXP HK4/11251440
BE2108R/VS8508Y 11NOV18LHREDI HK10/18202000
A97351 H 08NOV18MANMXP HK4/11251440`;
const subst = `\1-\5-\7`;
// 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