glob.glob()
does not use regex. it uses Unix path expansion rules. How can I emulate this regex in glob:
".*.jpg|.*.png"
glob.glob()
does not use regex. it uses Unix path expansion rules. How can I emulate this regex in glob:
".*.jpg|.*.png"
Well, with glob
you should just do this:
lst = glob.glob('*.jpg') + glob.glob('*.png')
@U12-Forward is correct that there isn't an exact solution but depending on your use case you might be able to solve it with the [...]
wildcard. For your example with .png
or .jpg
you could use this:
.*.[jp]*
which will match any extension that starts with a j or p
If you have other extensions that start with j or p you can be more specific:
.*.[jp][pn]g