Probably not a bug, since it's documented:
https://golang.org/pkg/regexp/syntax/
> Implementation restriction: The counting forms x{n,m}, x{n,}, and x{n}
reject forms that create a minimum
> or maximum repetition count above 1000. Unlimited repetitions are not
subject to this restriction.
I don't know the reason for such restriction. If I had to guess, I'd say
that's because the DFA approach
Go uses for regexp requires counting repetitions to be expanded into states
(they're not implemented
using a loop), so some kind of limit is needed to ensure the resulting
automata is not too big.
Alberto
On Sunday, 6 June 2021 at 08:12:41 UTC+2 M Hasbini wrote:
> Playground: https://play.golang.org/p/opVpDD5Ts8S
>
> Here's an example regex that fails to compile: `[a-zA-Z0-9]{1001,}`
>
> Here's where the 1000 is specified:
> https://github.com/golang/go/blob/4d9ecde/src/regexp/syntax/parse.go#L250
>
> Other languages regex engine behavior: The regex is valid on all languages
> in https://regex101.com/r/JzGrYG/1 except Go.
>
> Is there a reason for this limit or is this a bug?
>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/533c44b4-6e3b-4d8e-a27a-57993e76665bn%40googlegroups.com.