const regex = /(?<URL>\/upload(.+?)pdf).+?(?P<DATE>\d{2}\.\d{2}\.\d{4})/gs;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<URL>\\\/upload(.+?)pdf).+?(?P<DATE>\\d{2}\\.\\d{2}\\.\\d{4})', 'gs')
const str = `<div class="rasschetSredstv">
<table class="tab td_tac" border="0" cellpadding="10" cellspacing="0">
<tbody><tr>
<th width="17%">Январь</th>
<th width="17%">Февраль</th>
<th width="17%">Март</th>
<th width="17%">Апрель</th>
<th width="17%">Май</th>
<th width="17%">Июнь</th>
</tr>
<tr>
<td>
<a target="_blanc" href="/upload/iblock/2da/otchet_ss_310117.pdf">Скачать</a><br>
pdf(201 кБ)<br> (14.02.2017 12:44:00) </td>
<td>
<a target="_blanc" href="/upload/iblock/aa8/otchet_rss_na_sayt.pdf">Скачать</a><br>
pdf(196 кБ)<br> (15.03.2017 18:49:00) </td>
<td>
<a target="_blanc" href="/upload/iblock/71e/raschet_ss_na_sayt.pdf">Скачать</a><br>
pdf(197 кБ)<br> (14.04.2017 18:23:00) </td>
<td>
----
</td>
<td>
----
</td>
<td>
----
</td>
</tr>
<tr>
<th>Июль</th>
<th>Август</th>
<th>Сентябрь</th>
<th>Октябрь</th>
<th>Ноябрь</th>
<th>Декабрь</th>
</tr>
<tr>
<td>
----
</td>
<td>
----
</td>
<td>
----
</td>
<td>
----
</td>
<td>
----
</td>
<td>
----
</td>
</tr>
</tbody></table>
</div>`;
// 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