const regex = new RegExp('RIASWIX.*?Sky Access', 'gms')
const str = `----Document Start-------
Paragraph*
RIASWIX.* ABCDEF1 NONE
WORKING: HELLO(READ)
BOOLEAN Access: SADGRE3, VJFKES3, JGJKEWW, IS4DWF44(A), DFEAWE2(G),
DW4444W, IHFK3MF3
BAZAAR Access: No resource with BAZAAR Access
GHAR Access: No resource with GHAR Access
WATER Access: ADMINDDD(A), GEDDE33
SKY None: No Resource with Sky Access
RIASWIX.@7483NFJ.* HFDFDF3 NONE
WORKING: BYE(READ)
BOOLEAN Access: GRREGGG, GREFEFF, GFGGGG, FDFDFDF(A), RERERE3(G),
GFFWEF44, FFRF44F
BAZAAR Access: No resource with BAZAAR Access
GHAR Access: No resource with GHAR Access
WATER Access: ADMINEWW(A), FFRFRGR
SKY None: No Resource with Sky Access
RIASWIX.@7483KXX.* HFDFDF3 NONE
WORKING: TATA(READ)
BOOLEAN Access: GRDSD33, FASDE, GFGGGG, RWERW33(A), NMUYHT4(G),
BAZAAR Access: XCDFEFE3, FREFE33R
GHAR Access: No resource with GHAR Access
WATER Access: DASDEFG(A), SJMFEIOE(P)
SKY None: No Resource with Sky Access
*Text
----Document End-------`;
// 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