const regex = /^[0-9A-F]{32}$/img;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^[0-9A-F]{32}$', 'img')
const str = `fab4cc07260bc73302a2653aa2b0e6de
46cc38cc1039848dc287162cc4cf2532
a065c2cf24295a13725af9c5dc8cc76c
87d0f33c047915a0000ca972f3b32adc
43da9d5db71bedf3afc6f10fc8297a00
3fcca411d6774571a81a9faa4026c69a
9f36002354b2b75a069facac88ce5651
064ec24407084bf597c7dc1edc3f9017
3f5cfb400d72c7b3663b617368a0b3af`;
// 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