const regex = /^(?<atributo>(?<pai>(?:[^=.\n]+)\.?){1,6})=(?<valor>(?:[^=\n]+))$/gsm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^(?<atributo>(?<pai>(?:[^=.\\n]+)\\.?){1,6})=(?<valor>(?:[^=\\n]+))$', 'gsm')
const str = `php.environment.ini.session-name = sisicmbio
php.environment.ini.session-cookie_domain = icmbio.gov.br
php.environment.ini.session-auto_start = false
php.environment.ini.session-cookie_path = /
php.environment.ini.session-cookie_lifetime = 10800
php.environment.ini.session-cookie_httponly = true
php.environment.ini.session-use_only_cookie = true
php.environment.ini.session-gc_maxlifetime = 10800
php.environment.ini.session-cache_expire = 180
;; [php server mail]
php.mail.sender = smtp
php.mail.from = notifica@domain.gov.br ; conta default usada para enviar mensagens
php.mail.replyTo = reposta@domain.gov.br ; conta usada para reply
php.mail.wordWrap = 60
php.mail.priority = 3 ; 1: high, 3: normal, 5: low
php.mail.encoding = 8bit ; 8bit, 7bit, binary, base64, quoted-printable
php.mail.charset = utf-8
php.mail.contentType = text/html`;
// 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