Re: a regex question ..
- From: Gunnar Hjalmarsson <noreply@xxxxxxxxx>
- Date: Sat, 30 Apr 2005 20:10:59 +0200
Elvis Cehajic wrote:
Fabian Pilkowski wrote:
my $name = 'aaa2bbb3'; ( my $newname = $name ) =~ s/(\d)/0$1/g; # results in: $newname = 'aaa02bbb03'
Just keep in mind that this will change 'aaa11bbb12' to 'aaa0101bbb0102' which is probably not what the OP wants.
That's my interpretation as well. How about:
(my $newname = $name) =~ s/(^|\D)(\d)(?=\D|$)/${1}0$2/g;
rename $name, "new-$newname";-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl .
- Follow-Ups:
- Re: a regex question ..
- From: Geoff Cox
- Re: a regex question ..
- From: Geoff Cox
- Re: a regex question ..
- References:
- a regex question ..
- From: Geoff Cox
- Re: a regex question ..
- From: Fabian Pilkowski
- Re: a regex question ..
- From: Elvis Cehajic
- a regex question ..
- Prev by Date: Re: Performance question with a string concat
- Next by Date: Re: Looking for Perl Grammar
- Previous by thread: Re: a regex question ..
- Next by thread: Re: a regex question ..
- Index(es):