The ticket provides examples. [-] is interpreted as a character range, hence should be escaped. ? Is interpreted as any one character hence should be escaped.
regexp.QuoteMeta("01-Another Song-Album[Disc 2].flac")
01-Another Song-Album\[Disc 2\]\.flac
this helped in escaping special character
or we can use a general regex pattern to escape special characters
Ok, this does escape [-] but what about the other cases documented in in Match, such as c matching a character and not the letter c.
@AudriusButkevicius so should the simplest solution would probably to do a for range loop on string (which yield runes instead of bytes), and for each rune check if it is in our list of allowed/forbidden runes.
will this logic be good
Probably, it just needs to handle all the cases explained by Match docstring, and have tests to prove it works
Another option is to not glob at all, just list the directory entries and do a simpler prefix + suffix match. That should avoid the need for escaping, as we don’t really need to full power of glob patterns - we just want to find files with a known base name plus a variable suffix.
@calmh can you please provide an example
01-Another Song-Album[Disc 2].flac
like in this what according to you should be the result