If you have thousands of fixed strings, a map is your friend. Remarkably so.
On Wed, Jun 3, 2020 at 2:43 PM Ray Pereda <rayper...@gmail.com> wrote: > Typo fix, regexp#MatchString <https://golang.org/pkg/regexp/#MatchString> and > related Match functions are linear. That is an amazing guarantee and makes > regular > expressions 10x more useful than regexps in most other programming > languages. > > Question: Does the *compile* of regular expressions also guaranteed > linear runtime? I'm considering regular expressions with > 1000s of keywords; very long regexps. I looked at the source and it was > not obvious if that is the case. Intricate code. > > On Wednesday, June 3, 2020 at 10:07:12 AM UTC-7, Ray Pereda wrote: >> >> I believe that the complexity of regexp.MustCompile() >> <https://golang.org/pkg/regexp/#MustCompile> is linear based on this >> comment in the regexp package overview. >> <https://golang.org/pkg/regexp/#pkg-overview> >> >> "The regexp implementation provided by this package is guaranteed to run >> in time linear in the size of the input" >> >> >> What is the complexity of regexp.MustCompile() >> <https://golang.org/pkg/regexp/#MustCompile>? Is it linear in the length >> of the regular expression? >> >> -ray >> >> >> >> -- > 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 golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/f51125e7-f66e-45e8-af3a-381f96071d9a%40googlegroups.com > <https://groups.google.com/d/msgid/golang-nuts/f51125e7-f66e-45e8-af3a-381f96071d9a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- *Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>* -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CALoEmQy9TBAJo4Oz_wYsWvacDW_Q_y49bj%3DUCuY1tcdqSR5Ouw%40mail.gmail.com.