Multiply all numbers in a string
Update - Perl - 17

s/\d+/$&amp;*$^I/ge


15 characters + 2 for -i and -p flags.

We can use the -i flag to input a file extension, but since we aren't reading any files, we can use it to get the number and it the variable $^I will get assigned to it.

Run with:

perl -e'print"This 1 is22a 3352sentence 50"' | perl -i3 -pe's/\d+/$&amp;*$^I/ge'


Perl - 21

Updated as per @Dennis's comment.

$n=&lt;&gt;;s/\d+/$&amp;*$n/ge


Run with -p flag.

Example run:

perl -e'print"This 1 is22a 3352sentence 50\n3"' | perl -pe'$n=&lt;&gt;;s/\d+/$&amp;*$n/ge'


Explanation:

$n=&lt;&gt;; read in the number

-p prints the output

s/\d+/$&amp;*$n/ge Read the input with &lt;> and search for one or more digits and replace them with the digits times the number. g is global, e is eval the replace potion of the s///. $&amp; contains what was matched and it multiplied by the number, $n.

You can read more about s/// in perlop and more about Perl regexes in perlre.

Another solution:

@F.Hauri pointed out you can also use the s switch to assign the $n variable to 4. I'm not sure how many characters this counts as but I'll leave it here:

perl -spe 's/\d+/$&amp;*$n/ge' -- -n=4 &lt;&lt;&lt;'This 1 is22a 3352sentence 50'