regex - Python3: File Globbing by Whole Strings -


i understand file globbing in python3 well. however, official python3 documentation did not have on want ask. have folder many xaiml files (xml databases betabots). grouping files together. instance, used

glob.glob('./temp/xaiml2/[iijjkkllppqqrr]*.[xx][aa][ii][mm][ll]') 

so later put these files 1 file. here challenge, want group files start s, s, t, t, u, u, v, v, , dict8. yes, files starting full string may have other characters after it. have tried doing code [ssttuuvv'dict8'], glob command not ('syntaxerror: invalid syntax'). possible, , if so, how? glob.glob right command use?

you need use os.listdir() directory contents, , re.match() match filename contents.

[f f in os.listdir(somedir) if re.match(r'([s-v]|dict8).*\.xaiml', f, re.i)] 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -