const regex = new RegExp('da\\s+Secretaria\\s+de\\s+Estado\\s+de\\s+Planejamento\\s+e\\s+Gestão', 'gm')
const str = `NOMEAR ISABELLE FERREIRA ZARONI, ID FUNCIONAL Nº
5100796-7, para exercer, com validade a contar de 16 de novembro
de 2020, o cargo em comissão de Assessor, símbolo DAS-7, da Sub-
secretaria de Concessões e Parcerias, da Secretaria de Estado de
Planejamento e Gestão, anteriormente ocupado por Vinicius dos San-
tos Silva, ID Funcional n° 5108029-0. Processo nº SEI-
1 2 0 0 0 1 / 0 1 4 6 11 / 2 0 2 0 .`;
// 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