python find all file names in folder that follows a pattern
<p>I am trying to find all file names in a folder which follows this pattern: 'index_YYYYMMDD.csv'. The 'YYYYMMDD' part represents the date of the data file. Some of the files names are listed below:</p>

<p>'index_20091101.csv',
'index_20091102.csv',
'index_20091103.csv',
'index_20091104.csv',
'index_20091105.csv',
'index_20091106.csv',
'index_20091107.csv',
'index_20091108.csv',</p>

<p>Given a startDate and endDate, I would like to find all file names, the date part of which is between the startDate and endDate. For example, for the above file list, if the startDate=20091104 and endDate=20091107, the file names I would like to find should be:</p>

<p>'index_20091104.csv',
'index_20091105.csv',
'index_20091106.csv',
'index_20091107.csv'</p>

<p>I've tried os.listdir function, which gives me all the file names. To filter out the unwanted files, I think I need to use regular expression, but could not work it out. </p>

<p>Anyone could help me with this? Thanks!</p>