While doing some text replacements I found an unexpected behavior that can be replicated with this Lua shown bellow, I've tested with Lua 5.1 through 5.5 and LuaJIT, maybe I'm missing something subtle here, any help is welcome.
====
local txt2 = [===[
03.01.411A01.22700 Limpieza y aseo 1.210.830,00 0,00 0,00 0,00 1.210.830,00 0,00 1.075.110,90 88,79 1.021.998,36 84,40 871.196,21 71,95 150.802,15 188.831,64
Cuentas Anuales. Ejercicio 2024 Pág. 64
CUENTAS ANUALES DE LA ADMINISTRACIÓN GENERAL DE LA COMUNIDAD DE CASTILLA Y LEÓN. EJERCICIO 2024
EJECUCIÓN DEL PRESUPUESTO DE GASTOS DEL EJERCICIO 2024
GASTOS POR APLICACIÓN
ADMINISTRACIÓN GENERAL A FECHA DE 31/12/2024
APLICACION PRESUPUESTO INICIAL MODIFICACIONES MODIFICACIONES TOTAL PRESUPUESTO (2)/(1) % COMPROMISOS (3) (3)/(2) % OBLIGACIONES (4)/(2) % PAGOS (5)/(2) % OBLIG.PTES PAGO REMANENTES DE
(1) POSITIVAS NEGATIVAS MODIFICACIONES DEFINITIVO (2) RECONOCIDAS (4) REALIZADOS (5) CREDITO
03.01.411A01.22701 Seguridad 493.750,00 0,00 0,00 0,00 493.750,00 0,00 40.532,49 8,21 40.064,73 8,11 36.164,79 7,32 3.899,94 453.685,27
03.01.411A01.22703 Postales 1.212,00 0,00 0,00 0,00 1.212,00 0,00 1.208,23 99,69 1.208,23 99,69 1.208,23 99,69 0,00 3,77
03.01.411A01.22704 Custodia, depósito y almacenaje. 219.293,00 0,00 0,00 0,00 219.293,00 0,00 4.683,24 2,14 4.683,24 2,14 4.683,24 2,14 0,00 214.609,76
03.01.411A01.22706 Estudios y trabajos técnicos 257.392,00 0,00 0,00 0,00 257.392,00 0,00 185.197,25 71,95 185.197,14 71,95 143.786,77 55,86 41.410,37 72.194,86
]===]
local remove_re = [==[
Cuentas Anuales%. Ejercicio %d+ +Pág%. %d+
CUENTAS ANUALES DE LA ADMINISTRACIÓN GENERAL DE LA COMUNIDAD DE CASTILLA Y LEÓN%. EJERCICIO %d+
EJECUCIÓN DEL PRESUPUESTO DE GASTOS DEL EJERCICIO %d+
GASTOS POR APLICACIÓN
ADMINISTRACIÓN GENERAL[^\n]*
[^\n]+
[^\n]+
]==]
txt2 = txt2:gsub(remove_re, "")
print(txt2)
====
I'm expecting this output:
====
03.01.411A01.22700 Limpieza y aseo 1.210.830,00 0,00 0,00 0,00 1.210.830,00 0,00 1.075.110,90 88,79 1.021.998,36 84,40 871.196,21 71,95 150.802,15 188.831,64
03.01.411A01.22701 Seguridad 493.750,00 0,00 0,00 0,00 493.750,00 0,00 40.532,49 8,21 40.064,73 8,11 36.164,79 7,32 3.899,94 453.685,27
03.01.411A01.22703 Postales 1.212,00 0,00 0,00 0,00 1.212,00 0,00 1.208,23 99,69 1.208,23 99,69 1.208,23 99,69 0,00 3,77
03.01.411A01.22704 Custodia, depósito y almacenaje. 219.293,00 0,00 0,00 0,00 219.293,00 0,00 4.683,24 2,14 4.683,24 2,14 4.683,24 2,14 0,00 214.609,76
03.01.411A01.22706 Estudios y trabajos técnicos 257.392,00 0,00 0,00 0,00 257.392,00 0,00 185.197,25 71,95 185.197,14 71,95 143.786,77 55,86 41.410,37 72.194,86
====
but I'm getting this output:
====
03.01.411A01.22700 Limpieza y aseo 1.210.830,00 0,00 0,00 0,00 1.210.830,00 0,00 1.075.110,90 88,79 1.021.998,36 84,40 871.196,21 71,95 150.802,15 188.831,64
03.01.411A01.22704 Custodia, depósito y almacenaje. 219.293,00 0,00 0,00 0,00 219.293,00 0,00 4.683,24 2,14 4.683,24 2,14 4.683,24 2,14 0,00 214.609,76
03.01.411A01.22706 Estudios y trabajos técnicos 257.392,00 0,00 0,00 0,00 257.392,00 0,00 185.197,25 71,95 185.197,14 71,95 143.786,77 55,86 41.410,37 72.194,86
====
I've tested with pcre2 and javascript and I do get my expected output with this javascript:
====
const str = `
03.01.411A01.22700 Limpieza y aseo 1.210.830,00 0,00 0,00 0,00 1.210.830,00 0,00 1.075.110,90 88,79 1.021.998,36 84,40 871.196,21 71,95 150.802,15 188.831,64
Cuentas Anuales. Ejercicio 2024 Pág. 64
CUENTAS ANUALES DE LA ADMINISTRACIÓN GENERAL DE LA COMUNIDAD DE CASTILLA Y LEÓN. EJERCICIO 2024
EJECUCIÓN DEL PRESUPUESTO DE GASTOS DEL EJERCICIO 2024
GASTOS POR APLICACIÓN
ADMINISTRACIÓN GENERAL A FECHA DE 31/12/2024
APLICACION PRESUPUESTO INICIAL MODIFICACIONES MODIFICACIONES TOTAL PRESUPUESTO (2)/(1) % COMPROMISOS (3) (3)/(2) % OBLIGACIONES (4)/(2) % PAGOS (5)/(2) % OBLIG.PTES PAGO REMANENTES DE
(1) POSITIVAS NEGATIVAS MODIFICACIONES DEFINITIVO (2) RECONOCIDAS (4) REALIZADOS (5) CREDITO
03.01.411A01.22701 Seguridad 493.750,00 0,00 0,00 0,00 493.750,00 0,00 40.532,49 8,21 40.064,73 8,11 36.164,79 7,32 3.899,94 453.685,27
03.01.411A01.22703 Postales 1.212,00 0,00 0,00 0,00 1.212,00 0,00 1.208,23 99,69 1.208,23 99,69 1.208,23 99,69 0,00 3,77
03.01.411A01.22704 Custodia, depósito y almacenaje. 219.293,00 0,00 0,00 0,00 219.293,00 0,00 4.683,24 2,14 4.683,24 2,14 4.683,24 2,14 0,00 214.609,76
03.01.411A01.22706 Estudios y trabajos técnicos 257.392,00 0,00 0,00 0,00 257.392,00 0,00 185.197,25 71,95 185.197,14 71,95 143.786,77 55,86 41.410,37 72.194,86
`;
const regex = new RegExp(`
Cuentas Anuales\\. Ejercicio \\d+ +Pág\\. \\d+
CUENTAS ANUALES DE LA ADMINISTRACIÓN GENERAL DE LA COMUNIDAD DE CASTILLA Y LEÓN\\. EJERCICIO \\d+
EJECUCIÓN DEL PRESUPUESTO DE GASTOS DEL EJERCICIO \\d+
GASTOS POR APLICACIÓN
ADMINISTRACIÓN GENERAL[^\\n]*
[^\\n]+
[^\\n]+
`, 'g')
console.log(str.replaceAll(regex, ""));
====