const regex = new RegExp('SRR([0-9]+)([\\.])([0-9]+)([\\s]+)([A-Z]+)', 'gm')
const str = ` sequence_id cdr3_aa
0 SRR11610498.829751 AKDLGPDAGYTVFNDYFDN
1 SRR11610498.853725 AKDLGPDAGYTVFNDYFDN
2 SRR11610498.856922 AKDLGPDAGYTVFNHYFDN
3 SRR11610498.861591 AKDLGPDAGYTVFNDYFDN
4 SRR11610498.909314 AKDLGPDAGYTVFNDYFDN
5 SRR11610498.915768 AKDLGPDAGYTVFNDYFDN
6 SRR11610498.922245 ARGGLVVVDSFDY
7 SRR11610498.1017490 ASDLSYASSWLHYFDV
8 SRR11610498.1022079 ARLRFDNGALYFDY
9 SRR11610498.1037667 ASSAPPSGFNWFDP
10 SRR11610498.1111232 AKGPQIVATTTDNLEV
11 SRR11610498.1183596 AKDLGPDAGYTVFNDYFDN
`;
// 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