Reputation: 41
I am working on a project to delete files on a linux machine and I am thinking that using a regex pattern to select certain files and then delete them is the way to go. I'm am trying to match something on the lines of
abc_(alphanumeric)_(alphanumeric)_(two digit alphanumeric range)(arbitrary alphanumeric between 0 and 4 characters)_a.zip
or for example abc_1_2_(12-50)****_a.zip
where the stars can be any number.
I'm pretty sure I can figure most of this regex out myself, but is there any way to match any number of random numbers before the _a.zip
?
Upvotes: 2
Views: 8128
Reputation: 171
You're looking for * or +. * is zero or more occurrences, + is one or more. You'll have to finagle it a bit if you have a different requirement than that.
I'm a bit rusty on regex, but I believe something along the lines of
abc_[0-9]_[0-9]_([0-9][0-9]-[0-9][0-9])[0-9]+_a\.zip
is what you're looking for.
Upvotes: 0