On Thu, Nov 03, 2022 at 01:20:16PM -0700, pat2...@gmail.com wrote: > This has to be a FAQ, but my google foo for searching it is not clear > The docs say: " The syntax of patterns is the same as in path.Match." > > The pattern seems to implement only fairly simple search expressions. > > I'd like to search for "./*.MP4", but of course to be platform independant > I have to search for both upper and lower case "mp4" and "MP4" > and maybe even allow "Mp4". > > This is trivial in most regex, including go's regex > > Can I do this with Glob or DirWalk? Or do I need to just > get the file names and manually apply the regex?
The latter. But please note that I, for one, have not heard of any popular filesystem on a platform Go runs on which would support regexp matching when traversing its entries, and fs.Glob is largely modelled after what Unix shells implement. Hence basically if something like fs.Regexp were introduced, it would anyway need to walk the hierarchy and apply the supplied regexp to each pathname it visits. Please also note that using a regexp for what you're after looks like an overkill to me: a simple strings.EqualFold(filepath.Ext(fname), "mp4") in the callback function to fs.WalkDir wold convey the intent better, IMO. In any case, such a callback function to find a bunch of files matching their extensions in a case-insensitive manner would clock at 10-15 lines, I'd say. -- 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/20221104124713.vlglr7fm6azkxpap%40carbon.