Aug-10-2020, 06:44 PM
(This post was last modified: Aug-10-2020, 06:44 PM by deanhystad.)
Aaah, pattern is only for recursive search.
This is like doing globbing in the bash shell. Should make it easy to test. ls pattern,
I don't think you can do what you want to do, but you can do something close. The pattern is character based and it is not going to understand integers at all. But you can specify patterns that will match an integer range, just not any range. If you wanted to match 10 through 20 your pattern would be '*000[1-2][0-9].txt$'. This says match any number of characters followed by 000 then a 1 or 2, then any number 0-9 and ending with .txt.
I do not see how I could make my range 1..15 though, or 15..25 where part of the match depends on how the previous match was achieved. If my range is 10..20, the first digit has to be 1 or 2, but the range of the second digit is 0-9 if the first digit is 1, but only 0-5 if the first digit is 2.
I think this is easier solved by parsing the filenames yourself. Extract the part of the filename that is digits, convert to an integer and compare to your range. You could use glob to limit the files you test to only those that match your naming patter '*[0-9][0-9][0-9][0-9][0-9].txt$'
This is like doing globbing in the bash shell. Should make it easy to test. ls pattern,
I don't think you can do what you want to do, but you can do something close. The pattern is character based and it is not going to understand integers at all. But you can specify patterns that will match an integer range, just not any range. If you wanted to match 10 through 20 your pattern would be '*000[1-2][0-9].txt$'. This says match any number of characters followed by 000 then a 1 or 2, then any number 0-9 and ending with .txt.
I do not see how I could make my range 1..15 though, or 15..25 where part of the match depends on how the previous match was achieved. If my range is 10..20, the first digit has to be 1 or 2, but the range of the second digit is 0-9 if the first digit is 1, but only 0-5 if the first digit is 2.
I think this is easier solved by parsing the filenames yourself. Extract the part of the filename that is digits, convert to an integer and compare to your range. You could use glob to limit the files you test to only those that match your naming patter '*[0-9][0-9][0-9][0-9][0-9].txt$'