Re: I think I found a bug in Lua string.patterns, can anyone help see if it's true ?
Spar <[email protected]> Tue, 12 May 2026 15:40:55 +0300
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <577fee90-1c46-416f-8dbd-fca7c30ed3c0@Spark> |
That's what I said :)
Pretend like the input box is a [[ ]] literal.
YOu need to either use `"` literal for your pattern or gsub("\\n", "\n")
On May 12, 2026 at 15:39 +0300, Domingo Alvarez Duarte <[email protected]>, wrote:
> Hello Spar ! Your tool doesn't seem to interpret '[^\n]' properly:
> ```
> [^...]Inverse set.Matches any character except:
> \Character.Doesn't match "\" literally.
> nCharacter.Doesn't match "n" literally.
> *Quantifier (zero or more).Allows to match the pattern zero or more times. This will match the longest sequence.
> ```
>
> > On Tuesday, May 12, 2026 at 2:35:14 PM UTC+2 Domingo Alvarez Duarte wrote:
> > > Here is the pattern after `remove_re:gsub("\n", "\\n")` that I'm now looking at your tool:
> > > ====
> > > \n\n\nCuentas Anuales%. Ejercicio %d+ +Pág%. %d+\n CUENTAS ANUALES DE LA ADMINISTRACIÓN GENERAL DE LA COMUNIDAD DE CASTILLA Y LEÓN%. EJERCICIO %d+\n\n\nEJECUCIÓN DEL PRESUPUESTO DE GASTOS DEL EJERCICIO %d+\nGASTOS POR APLICACIÓN\nADMINISTRACIÓN GENERAL[^\n]*\n[^\n]+\n\n[^\n]+\n\n
> > > ====
> > >
> > > > On Tuesday, May 12, 2026 at 2:21:24 PM UTC+2 Spar wrote:
> > > > > Correction. It's not actually the \n. It's because you used `[[ ]]` string literals which works as C++ raw literals. They don't accept escapes.
> > > > >
> > > > > So what actually happens can be described by my tool which doesn't accept escapes too (i will fix it some day) :-)
> > > > >
> > > > > https://gitspartv.github.io/lua-patterns/?pattern=%5B%5E%5Cn%5D*
> > > > > On May 12, 2026 at 15:20 +0300, Luiz Henrique de Figueiredo <[email protected]>, wrote:
> > > > > > Try this simple pattern
> > > > > >
> > > > > > local remove_re = "Cuentas Anuales.-CREDITO%s+"
> > > > > >
> > > > > > --
> > > > > > You received this message because you are subscribed to the Google Groups "lua-l" group.
> > > > > > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> > > > > > To view this discussion visit https://groups.google.com/d/msgid/lua-l/CABt16qnGEsb6UYWW66PHzj6gey5g9AqWUCHpB7_zYA8P6N8Zag%40mail.gmail.com.
> --
> You received this message because you are subscribed to the Google Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/6af79f2d-6de5-4c91-ad88-0bc68aa28d13n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/577fee90-1c46-416f-8dbd-fca7c30ed3c0%40Spark.