const regex = /^()/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^()', 'gm')
const str = `недревесное сырье:,Актинидия (15) 0,7 м,1,5 кг/га
недревесное сырье:,Калина (10) 1,2 м,0,1 кг/га
недревесное сырье:,Актинидия (15) 0,7 м,3,5 кг/га,Лимонник (15) 3,5 м,3,5 кг/га,
недревесное сырье:,Лимонник (10) 2,0 м,1,0 кг/га
недревесное сырье:,ЭЛЕУТЕРОКОКК (5) 2,0 м,0,5 кг/га
недревесное сырье:,Лимонник (10) 2,0 м,0,2 кг/га,Виноград (10) 2,0 м,0,1 кг/га
недревесное сырье:кедровый орех,аралия (5) 2,4 м,1,8 кг/га
недревесное сырье:орехи,Лещина (10) 5,0 м,20,0 кг/га
недревесное сырье:,Актинидия (10) 0,4 м,3,5 кг/га,Виноград (15) 0,3 м,0,2 кг/га
`;
// 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