const regex = /^(build|ci|docs|feat|fix|perf|refactor|style|test)(|!): [a-z].+?((, fixes #\d+)*)($|\n|\r|\n\r)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(build|ci|docs|feat|fix|perf|refactor|style|test)(|!): [a-z].+?((, fixes #\\d+)*)($|\\n|\\r|\\n\\r)', 'gm')
const str = `Remove 'ddev pause' and its tests
Add healthcheck to router so we wait for it to be started
Add new Amplitude Property DDEV-Environment
test: optimize caching of downloaded assets
docs: auto create commands documentation
docs: re-introduce Rancher Desktop docs
fix: avoid type: php to detected project type but instead show a warning, fixes #4403, fixes #1234
build: bump docker-compose to 2.19.0
feat: allow multiple upload dirs, fixes #4190, fixes #4796
feat!: add ddev dbeaver command, fixes #4947
docs: add more extensive custom command examples, fixes #4926
refactor: enabled Mutagen by default on Mac and Windows, fixes #4637
refactor: avoid calling stop hooks if app is already stopped
`;
// 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