'Python Glob doesn't recognize file pattern with arbitary numbers 2 to 12 in a path string
Is there a way to get an OR condition inside the file path for glob to recognize it? something like source_path = path + ('[1-9]+'|'[1-9][0-1]+'), mainly to recognize file with filename as (just an exaample):
filename_2,
filename_3,
filename_10,
filename_11,
import glob
source_path = path + '[1-11]*'
for file in gb.glob(source_path):
print('file=', file) #'--gives no output
source_path = path + '[1-9]*'
for file in glob.glob(source_path):
print('file=', file)
This code only detects filename_2 and filename_3.
Solution 1:[1]
Number of items to match the file name : 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11 something like this works:
0[1-9]|1[0-1]
For more information read this .regular-expressions.info
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
