Wildcard string matching on linux
If you’re on linux, the GNU C library has a handy function for doing wildcard matching called fnmatch. I notice it’s also supported in Python, PHP and Perl and probably in a few other scripting languages.
I’m amazed that I haven’t ever needed to do this before but I had the case this year that I needed to allow a list of strings to contain wildcards. At first I just implemented this myself as I only needed to support the wildcard on the ends of strings but once I started using it, I wanted to allow matching the wildcard in the middle of strings too. That’s the point at which I realised I’d need some kind of stack and parsing and grammar so after 3 seconds on Google, I found fnmatch. It’s times like this you wonder why you didn’t just look this up in the first place.
