const regex = /
(\d+)\t(\d+)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('
(\\d+)\\t(\\d+)', 'gm')
const str = `
6 9
6 10
8 11
9 12
10 13
11 14
12 15
13 16
14 17
15 18
16 19
17 20
18 21
19 22
20 23
5 24
4 25
21 26
22 27
1 28
23 29
24 30
25 31
26 32
27 33
28 34
29 35
30 36
31 37
32 38
33 39
34 40
35 41
36 42
37 43
38 44
39 45
40 46
41 47
42 48
43 49
44 50
45 51
46 52
47 53
48 54
49 55`;
const subst = `INSERT INTO loyalty_rule(rule_id_fk, loyalty_id_fk) VALUES ($1, $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