a regex question ..
- From: Geoff Cox <geoff.cox@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 30 Apr 2005 17:20:53 GMT
Hello
I am trying to rename a list of files by changing any single digits in
the names to a zero and the digit, eg 7 -> 07.
Problem is there may be 2 instances in the name and the code below
only works for the first single digit - how can I deal with both
instances?
if ($name =~ /^(.*?)\-(\d{1})\D(.*?)$/ ) {
my $num = $2;
rename ($name, "new-" . $1 . "-" . "0" . $num . "-" . $3);
I have tried using tr/// but cannot see how to do it.
My guess would be that the above is not the best way to go about this!
Cheers
Geoff
.
- Follow-Ups:
- Re: a regex question ..
- From: John W. Krahn
- Re: a regex question ..
- From: Fabian Pilkowski
- Re: a regex question ..
- Prev by Date: Re: About formatting
- Next by Date: Re: a regex question ..
- Previous by thread: FAQ 3.31 What's MakeMaker?
- Next by thread: Re: a regex question ..
- Index(es):
Relevant Pages
|