const regex = /(?>[^;]*;){5}(?>[^,]*,){2}\s*[^,^\s]*\s*([^,^;]*)(?>[^;^\r^\n]*)/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?>[^;]*;){5}(?>[^,]*,){2}\\s*[^,^\\s]*\\s*([^,^;]*)(?>[^;^\\r^\\n]*)', 'g')
const str = `2009311179;2723088770;Комсомольское отделение филиала ПАО "ДЭК"-"Хабаровскэнергосбыт";2018-10-23;0de159ee-ebc3-4a1e-81ca-63d8fe5a8558;1093163;Хабаровский край, Солнечный район, п. Хурмули, ул. Школьная, д. 20;;Солнечный;;;421;;Школьная;529;20;;;7;1;16;2012-08-01;65,1;41,3;2012-08-01;3;1;12DEC0701E80601161;;2012-08-01;;Капарушкин;Виталий;Викторович;;;4;4;;2012-08-01`;
// 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