in reply to need regular expression

$var1=~s/\.xml$/.jpg/;

This would substitute .xml at the end of a string with .jpg. '$' matches at end of string, '.' has to be escaped with '\' since it would have special meaning otherwise.

Replies are listed 'Best First'.
Re^2: need regular expression
by techtween (Novice) on Jul 13, 2011 at 12:21 UTC
    thanks jethro, but still its unfinished coz, $var1= ab_db_1.xml when print $var1 is given i need result as, ab_db_thumb_1.jpg kindly note the difference.

      You have been given the approach that you would use. See perlre for more information. To get more assistance, please show what you have tried. We try to teach you how to do your work -- we do not do your work for you.

      --MidLifeXis