Closed jrwrigh closed 3 years ago
The following regex string works for the above cases: ^velbar\.200(?!\d).*$
Effectively, after 200, if the next character is a digit, the matching fails. Otherwise, it succeeds with any other characters.
In [5]: os.listdir('.')
Out[5]: ['velbar.200', 'velbar.200.1', 'velbar.2000']
In [6]: for filename in filter(re.compile(r'^velbar\.200(?!\d).*$').match, os.listdir('.')):
...: print(filename)
...:
velbar.200
velbar.200.1
Instead of just globbing
velbar*.{timestep number}*
, have it be more strict by only allowing the*
to apply for file extensions.Example: For time step number = 200: Match:
Fail: