const regex = /((\bprostat)(?=\w{0,3}\b))/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('((\\bprostat)(?=\\w{0,3}\\b))', 'gm')
const str = `/*ITALIAN*/
Neoformazione del palato duro in paziente affetto da ca della prostata.
Frustoli agoboptici di parenchima prostatico.
Il complesso dei reperti orienta in prima ipotesi per localizzazione di carcinoma di origine prostatica.
Agobiopsie prostatiche multiple
Ipertrofia prostatica.
/*ENGLISH*/
New formation of the hard palate in a patient affected by prostate cancer.
Fragments showing hypertrophic prostate parenchyma.
The combination of findings suggests a preliminary diagnosis of prostate-origin carcinoma.
Multiple prostatic core biopsies.
Prostatic hypertrophy.`;
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