const regex = /(fg\w+)?(\s)?(\d+|\w+)([\/\._]+\w+)([\/\._ ]?)(\d+)(\w?)/gmi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(fg\\w+)?(\\s)?(\\d+|\\w+)([\\\/\\._]+\\w+)([\\\/\\._ ]?)(\\d+)(\\w?)', 'gmi')
const str = `Trans 16 10.2/300 Vor-, täglich
InnoTrans 16 Reinigung 23/705 Vorr./Tägl.
InnoTrans 16 Reinigung 17/113 Vorr./Tägl.
FUNK 16 Reinigung 14.1/124 Vorr./Tägl.
InnoTrans 16 Reinigung FGSUED O/240 Vorr./Tägl.
InnoTrans 16 Reinigung 6.2/507 Vorr./Tägl.
Trans 16, 23/606, Vor + tägl. Reinigung
InnoTrans 16 Reinigung 26./141 Vorr./Tägl.
InnoTrans 16 Reinigung FGSUED O/553 Reinigung Aufbau+Gl./Tägl.+Gl.
Inno 16 Vorr. + tägl. Rein. H. 17_304
trans 4.1 412 vor u tä
InnoTrans 16 Reinigung FGSUED T10/47 Reinigung nach Stundennachweis
Inno 16 Vorr. + tägl. rein. H. 7.2C_305
Inno 16 - Storno H. 22_808
STORNO !!!!!!InnoTrans 16 Reinigung 4.2/208a Vorr./Tägl.
innotrans 16 reinig tä 21. 205`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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