HI all,
Kindly go through the code below. use warnings; use strict; my $i=1; while($i<=10) { $_ = "abcpqr"; $_=~ s/(?=pqr)/$i/; print "$_\n"; $i++; } Output: abc1pqr abc2pqr abc3pqr abc4pqr abc5pqr abc6pqr abc7pqr abc8pqr abc9pqr abc10pqr The expected output is abc001pqr abc002pqr abc003pqr abc004pqr abc005pqr abc006pqr abc007pqr abc008pqr abc009pqr abc010pqr Can any one suggest me how to get that output using regex. i.e. Can this happen by making change in regex I used in code??