I'm afraid I have to contradict that answer (from an AI chatbot perhaps?) Go's regexp library, called re2, is documented here: https://github.com/google/re2/wiki/Syntax
It *does* support the \w character class. See the section headed "Perl character classes (all ASCII-only)". Furthermore, the OP was successfully using \w with go 1.20.7. The problem arose with 1.21 and is something to do with plugin loading or initialization. On Monday, 4 September 2023 at 17:56:32 UTC+1 Google's Affiliate (Google Business Affiliate) wrote: > Hello, this is Jonathan, I can help you with your question about the error > parsing regexp in Go. > > The error you are getting is caused by the use of \w in your regular > expression. This is an invalid escape sequence in Go, because \w is not a > predefined character class > <https://stackoverflow.com/questions/6770898/unknown-escape-sequence-error-in-go> > 1 > <https://stackoverflow.com/questions/6770898/unknown-escape-sequence-error-in-go> > . Go only supports the following escape sequences in regular expressions > <https://www.bing.com/search?form=MY0291&OCID=MY0291&q=Bing+AI&showconv=1#> > 2 > <https://stackoverflow.com/questions/24836885/go-regex-error-parsing-regexp-invalid-escape-sequence-k> > : > > - \t for tab > - \n for newline > - \r for carriage return > - \f for form feed > - \a for alert > - \b for word boundary > - \B for non-word boundary > - \d for decimal digit > - \D for non-decimal digit > - \s for whitespace character > - \S for non-whitespace character > - \w for word character (alphanumeric plus _) > - \W for non-word character > > To match a word character in Go, you need to use [[:word:]], which is > equivalent to [0-9A-Za-z_]. Alternatively, you can use [[:alnum:]]_, > which is equivalent to [0-9A-Za-z]_. So, your regular expression should > be: > > regexp.Compile(`^([[:word:]./]+)/((?:[[:word:]]+)|[*])(.+)?$`) > > or > > regexp.Compile(`^([[:alnum:]_./]+)/((?:[[:alnum:]_]+)|[*])(.+)?$`) > > This should fix the error and allow you to load the plugin successfully. > > I hope this helps you with your problem. If you have any further > questions, please feel free to ask. 😊 > > > > On Sunday, September 3, 2023 at 4:47:39 AM UTC-4 Olivier Szika wrote: > >> Hi, >> >> Unexpectedly, unicode.Categories is an empty map when it's only used with >> a plugin. >> I opened a ticket: https://github.com/golang/go/issues/62430 >> >> Regards, >> >> Le samedi 12 août 2023 à 18:13:31 UTC+2, Wojciech S. Czarnecki a écrit : >> >>> Dnia 2023-08-08, o godz. 18:11:56 >>> Bernd Fix <b...@hoi-polloi.org> napisał(a): >>> >>> > After switching from go1.20.7 to go1.21.0 one of my applications >>> > compiles without warnings or errors, but fails at run-time with the >>> > following panic when loading a plugin: >>> >>> IIRC release notes tools now are version aware, so likely you need to >>> bring >>> all go.mod's version to state 1.21.0 >>> >>> hope this helps, >>> >>> > Cheers, Bernd. >>> > >>> >>> -- 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/e43019b7-3fd7-4163-ac9f-c7b6e5465204n%40googlegroups.com.