const regex = /(?<=(;\d{4}-\d\d-\d\d\n))((?:[^;]++|;)*?)\1/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=(;\\d{4}-\\d\\d-\\d\\d\\n))((?:[^;]++|;)*?)\\1', 'g')
const str = `№;Задача;T;O;P
;2016-01-18
1. ;task1;03:00;.;
;2016-01-18
2. ;task2;03:00;.;
;2016-01-18
3. ;task3;03:00;.;
;2016-01-19
7. ;33333;03:00;.;
;2016-01-19
8. ;d;03:00;.;
;2016-01-19
9. ;00;03:00;.;
;2016-01-20
21. ;task1;03:00;.;
;2016-01-20
22. ;task2;03:00;.;
;2016-01-21
25. ;testtime;03:00;.;
;2016-01-21
26. ;fgghgfh;23:45;.;, new t.`;
const subst = `\2`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
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