Sum of integers in string, separated by non-numericals such as 'a' and 'Y'

Ruby 1.9, 21 characters

eval a.scan(/\d+/)*?+

To print the solution to stdout, 2 additional characters are required:

p eval a.scan(/\d+/)*?+

And to read from stdin instead of using a predefined variable, another 3 characters have to be used:

p eval gets.scan(/\d+/)*?+

For Ruby 1.8, replace ?+ with "+" to get a working solution in 22 characters.


Perl, 15

Input in $_, sum in $c:

s/\d+/$c+=$&/ge

Ruby - 36 34 chars

s.scan(/\d+/).map(&:to_i).reduce:+

36 chars if you want the result printed.

p s.scan(/\d+/).map(&:to_i).reduce:+

Assumes the input is present as a string in s.