$text = "I am 17 years old"; $text =~ s/(\d+)/2 * $1/eg; #now I am 34 years old