Case-insensitive globbing

Eddie Corns eddie at holyrood.ed.ac.uk
Thu Jun 3 20:03:15 CEST 2004


tkpmep at hotmail.com (Thomas Philips) writes:

>I'm using the function glob from module glob to obtain a list of all
>files in a directory that match a pattern. Unfortunately, some
>filenames are in upper case, others are in lower case and yet others
>are in mixed case. How can I do a case-insenstive glob that picks up
>all files that match a string regardless of case? If its any help, I'm
>running Python 2.3.4 under Windows XP.

If it works the same as it does on Unix then you can use the [Xx] construct
for each of the characters, eg *[Ff][Oo][Oo]*  but I'll bet there are better
ways to do the task.

Eddie



More information about the Python-list mailing list