const regex = /\<yes or no\. if yes, explain why\>|\<yes\/no\>/gi;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\<yes or no\\. if yes, explain why\\>|\\<yes\\\/no\\>', 'gi')
const str = `* Document with a Yes or No if your story impacts any of the following hazard types. If yes, explain why.
** Financial: <yes or no. If yes, explain why>
** Legal/Regulatory: <yes or no. If yes, explain why>
** Data Integrity: <yes or no. If yes, explain why>
** Patient Safety: <yes or no. If yes, explain why>
** CyberSecurity/Information Security: <yes or no. If yes, explain why>
* Engineer assigned to the project has added a +1 indicating that they discussed the impact this story has with regards to Hazards and agrees with the assessment.
- *Financial:* <yes or no. If yes, explain why>
- *Legal/Regulatory:* <yes or no. If yes, explain why>
- *Data Integrity:* <yes or no. If yes, explain why>
- *Patient Safety:* <yes or no. If yes, explain why>
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why>
- *Financial:* <yes/no>
- *Legal/Regulatory:* <yes/no>
- *Data Integrity:* <yes/no>
- *Patient Safety:* <yes/no>
- *CyberSecurity/Information Security:* <yes/no>
- *Financial:* <yes or no. If yes, explain why>No
- *Legal/Regulatory:* <yes or no. If yes, explain why> Yes
- *Data Integrity:* No
- *Patient Safety:* Yes, this was an issue because of XYZ.
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why>
- *Financial:* no
- *Legal/Regulatory:* no
- *Data Integrity:* no
- *Patient Safety:* no
- *CyberSecurity/Information Security:* no
- *Financial:* N
- *Legal/Regulatory:* N
- *Data Integrity:* N
- *Patient Safety:* N
- *CyberSecurity/Information Security:* N
- *Financial:* <yes or no. If yes, explain why>N
- *Legal/Regulatory:* <yes or no. If yes, explain why> N
- *Data Integrity:* <yes or no. If yes, explain why>N
- *Patient Safety:* <yes or no. If yes, explain why>N
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why> N
- *Financial:* <yes or no. If yes, explain why>
- *Legal/Regulatory:* <yes or no. If yes, explain why>
- *Data Integrity:* <yes or no. If yes, explain why>
- *Patient Safety:* <yes or no. If yes, explain why>
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why>
- *Financial:* <yes/no>
- *Legal/Regulatory:* <yes/no>
- *Data Integrity:* <yes/no>
- *Patient Safety:* <yes/no>
- *CyberSecurity/Information Security:* <yes/no>
- *Financial:* <yes or no. If yes, explain why>No
- *Legal/Regulatory:* <yes or no. If yes, explain why> Yes
- *Data Integrity:* No
- *Patient Safety:* Yes, this was an issue because of XYZ.
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why>
- *Financial:* no
- *Legal/Regulatory:* no
- *Data Integrity:* no
- *Patient Safety:* no
- *CyberSecurity/Information Security:* no
- *Financial:* N
- *Legal/Regulatory:* N
- *Data Integrity:* N
- *Patient Safety:* N
- *CyberSecurity/Information Security:* N
- *Financial:* <yes or no. If yes, explain why>N
- *Legal/Regulatory:* <yes or no. If yes, explain why> N
- *Data Integrity:* <yes or no. If yes, explain why>N
- *Patient Safety:* <yes or no. If yes, explain why>N
- *CyberSecurity/Information Security:* <yes or no. If yes, explain why> N
`;
// 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