[Question]
  [
### Task
The task is very simple. Given a non-empty string containing **numbers**, **uppercase** and **lowercase letters**, output the sum of the remaining numbers. For example:
```
a1wAD5qw45REs5Fw4eRQR33wqe4WE
```
Filtering out all the letters would result into:
```
 1   5  45   5  4    33   4
```
The sum of these numbers is `1 + 5 + 45 + 5 + 4 + 33 + 4 = 97`. So the output would be `97`.
### Test Cases
```
a > 0
0 > 0
5 > 5
10 > 10
a0A > 0
1a1 > 2
11a1 > 12
4dasQWE65asAs5dAa5dWD > 79
a1wAD5qw45REs5Fw4eRQR33wqe4WE > 97
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the submission with the least amount of bytes wins!
  
[Answer]
# GS2, 2 bytes
```
Wd
```
[Try it online!](http://gs2.tryitonline.net/#code=V2Q&input=YTF3QUQ1cXc0NVJFczVGdzRlUlFSMzN3cWU0V0U)
### How it works
```
W     Read all numbers.
      For input x, this executes map(int, re.findall(r'-?\d+', x)) internally.
 d    Compute their sum.
```
[Answer]
## [Labyrinth](https://github.com/mbuettner/labyrinth), 8 bytes
Take that, Pyth...
```
?+
;,;!@
```
[Try it online!](http://labyrinth.tryitonline.net/#code=PysKOyw7IUA&input=YTF3QUQ1cXc0NVJFczVGdzRlUlFSMzN3cWU0V0U)
### Explanation
The usual primer (stolen from Sp3000):
* Labyrinth is 2D and stack-based. Stacks have an infinite number of zeroes on the bottom.
* When the instruction pointer reaches a junction, it checks the top of the stack to determine where to turn next. Negative is left, zero is forward and positive is right.
What comes in really handy here is that Labyrinth has two different input commands, `,` and `?`. The former reads a single byte from STDIN, or `-1` at EOF. The latter reads an integer from STDIN. It does so skipping everything that *isn't* a number and then reads the first decimal number it finds. This one returns `0` at EOF, so we can't use it to check for EOF reliably here.
The main loop of the program is this compact bit:
```
?+
;,
```
With `?` we read an integer (ignoring all letters), with `+` we add it to the running total (which starts out as one of the implicit zeroes at the stack bottom). Then we read another character with `,` to check for EOF. As long as we're not at EOF, the read character will be a letter which has a positive character code, so the IP turns right (from its point of view; i.e. west). `;` discards the character because we don't need it and then we enter the loop again.
Once we're at EOF, `,` pushes a `-1` so the IP turns left (east) instead. `;` again discards that `-1`, `!` prints the running total as an integer and `@` terminates the program.
[Answer]
# [MATL](https://esolangs.org/wiki/MATL), 8 bytes
```
1Y4XXXUs
```
[**Try it online!**](http://matl.tryitonline.net/#code=MVk0WFhYVXM&input=JzRkYXNRV0U2NWFzQXM1ZEFhNWRXRCc)
```
1Y4      % predefined literal: '\d+'
XX       % implicit input. Match regular expression. Returns a cell array of strings
         % representing numbers
XU       % convert each string to a double. Returns a numeric array
s        % sum of numeric array
```
[Answer]
## CJam, 13 bytes
Fixed to work with input without numbers thanks to Dennis! Also saved a byte by replacing the letters array with an array of ASCII above code point 64. And then another byte saved by Dennis!
```
q_A,s-Ser~]1b
```
Simple transliteration from letters to spaces, then eval and sum. [Try it online](http://cjam.aditsu.net/#code=q_A%2Cs-Ser%7E%5D1b&input=a3bv6).
[Answer]
# JavaScript ES6, 35 bytes
```
s=>eval(s.replace(/\D+/g,'+')+'.0')
```
### How it works
First, we replace each string of non-digits with `"+"`. There are basically four different ways that this could end up:
```
1. 1b23c456   => 1+23+456
2. a1b23c456  => +1+23+456
3. 1b23c456d  => 1+23+456+
4. a1b23c456d => +1+23+456+
```
Cases 1 and 2 are taken care of already. But we somehow need to fix the last `+` so that it doesn't cause an error. We could remove it with `.replace(/\+$,"")`, but that's too expensive. We could append a `0` to the end, but that would affect the last number if the string does not end with a `+`. A compromise is to append `.0`, which is both a valid number on its own and doesn't affect the value of other integers.
Here's a few other values that would work as well:
```
.0
-0
 +0
-""
-[]
0/10
0e-1
.1-.1
```
### Alternate version, also 35 bytes
```
s=>s.replace(/\d+/g,d=>t+=+d,t=0)|t
```
### Another alternate version, 36 bytes
```
s=>s.split(/\D/).map(d=>t+=+d,t=0)|t
```
[Answer]
# [Retina](https://github.com/mbuettner/retina), ~~22~~ 11
```
\d+
$0$*1
1
```
[Try it online!](http://retina.tryitonline.net/#code=XGQrCiQwJCoxCjE&input=YTF3QUQ1cXc0NVJFczVGdzRlUlFSMzN3cWU0V0U)
11 bytes (!) saved thanks to Martin!
Basically just decimal to unary then count the `1`s.
[Answer]
# Japt, 2 bytes
```
Nx
```
[Test it online!](http://ethproductions.github.io/japt?v=master&code=Tng=&input=YTF3QUQ1cXc0NVJFczVGdzRlUlFSMzN3cWU0V0U=)
### How it works
```
N    // Implicit: N = (parse input for numbers, "strings", and [arrays])
x    // Sum. Implicit output.
```
[Answer]
## Pyth, ~~12~~ ~~11~~ 10 bytes
```
ssM:z"\D"3
```
```
    z        autoinitialized to input()
   : "\D"3   split on non-digits
 sM          convert all elements of resulting array to ints
s            sum
```
Fortunately, `s` (convert to int) returns `0` when applied to the empty string, so I don't have to worry about the fact that `split("a1b", "\D+")` returns `["", "1", ""]`. Similarly, `split("a", "\D+")` returns `["", ""]`.
This even allows me to split on every non-digit individually, since `1 + 0 + 0 + 0 + 0 + 2` is the same thing as `1 + 2`.
Thanks to [Thomas Kwa](https://codegolf.stackexchange.com/users/39328/thomas-kwa) for a byte!
[Answer]
# [Gol><>](https://golfish.herokuapp.com/), 4 bytes
```
iEh+
```
So short I need dummy text...
[Answer]
# [Perl 6](http://perl6.org), 18 bytes
```
{[+] .comb(/\d+/)}
{[+] .split(/\D/)}
```
### Usage:
```
my &code = {[+] .comb(/\d+/)}
say code 'a'; # 0
say code '0'; # 0
say code '5'; # 5
say code '10'; # 10
say code 'a0A'; # 0
say code '1a1'; # 2
say code '11a1'; # 12
say code '4dasQWE65asAs5dAa5dWD'; # 79
say code 'a1wAD5qw45REs5Fw4eRQR33wqe4WE'; # 97
```
[Answer]
# Jelly, 6 bytes
```
&-ṣ-ḌS
```
[Try it online!](http://jelly.tryitonline.net/#code=Ji3huaMt4biMUw&input=&args=ImExd0FENXF3NDVSRXM1Rnc0ZVJRUjMzd3FlNFdFIg)
### How it works
```
&-ṣ-ḌS  Main link. Input: L (string)
&-      Take the bitwise AND of L's characters and -1.
        This attempts to cast to int, so '0' & -1 -> 0 & -1 -> 0.
        On failure, it returns the integer argument (if any), so 'a' & -1 -> -1.
  ṣ-    Split the resulting list at occurrences of -1.
    Ḍ   Convert each chunk from decimal to integer. In particular, [] -> 0.
     S  Compute the sum of the results.
```
[Answer]
# Perl, 21 + 1 = 22 bytes
```
$_=eval join"+",/\d+/g
```
Requires the `-p` flag:
```
$ perl -pe'$_=eval join"+",/\d+/g' <<< 'a1wAD5qw45REs5Fw4eRQR33wqe4WE'
97
```
[Answer]
# Julia, 35 bytes
```
s->sum(parse,matchall(r"\d+","0"s))
```
This is an anonymous function that accepts a string and returns an integer. To call it, assign it to a variable.
We use `matchall` to get an array consisting of matches of the regular expression `\d+`, which are just the integers in the string. We have to tack on a 0 to the front of the string, otherwise for cases like `"a"`, we'd be summing over an empty array, which causes an error. We then apply `parse` to each string match, which converts to integers, and take the sum.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `s`, 4 bytes
```
⁽±Ḋ⌊
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyJQcyIsIiIsIuKBvcKx4biK4oyKIiwiIiwiNGRhc1FXRTY1YXNBczVkQWE1ZFdEICJd)
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-n`, 23 bytes
Based on [Ventero’s answer here](https://codegolf.stackexchange.com/a/742/11261).
```
p eval$_.scan(/\d+/)*?+
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpclm0km6eUuyCpaUlaboW2wsUUssSc1Ti9YqTE_M09GNStPU1tey1IbJQRQv2JhqWO7qYFpabmAa5Fpu6lZukBgUGGRuXF6aahLtCFAEA)
[Answer]
# PHP, 64 bytes
```
<?php preg_match_all("/\d+/",$argv[1],$a);echo array_sum($a[0]);
```
Run it as
```
php -f filterOutAndAddUp.php <test_case>
```
<https://eval.in/517817>
[Answer]
# Javascript, ~~32~~ 39 bytes
```
s=>eval((s.match(/\d+/g)||[0]).join`+`)
```
```
f=
s=>eval((s.match(/\d+/g)||[0]).join`+`)
F=s=>document.body.innerHTML+='<pre>f(\''+s+'\') -> '+f(s)+'\n</pre>'
F('a')
F('5')
F('10')
F('1a1')
F('11a1')
F('4dasQWE65asAs5dAa5dWD')
F('a1wAD5qw45REs5Fw4eRQR33wqe4WE')
```
[Answer]
# Mathematica, 51 bytes
```
Total@ToExpression@StringCases[#,DigitCharacter..]&
```
Catching the wrong end of the verbose Mathematica builtins. 1 Byte off with the help of @DavidC
[Answer]
# R, ~~46~~ 43 bytes
```
sum(strtoi(strsplit(scan(,''),'\\D')[[1]]))
```
**Explanation**
```
                    scan(,'')                  # Take the input string
           strsplit(         ,'\\D')           # Returns list of all numeric parts of the string
                                    [[1]]      # Unlists to character vector
    strtoi(                              )     # Converts to numeric vector
sum(                                      )    # Sums the numbers
```
**Sample run**
```
> sum(strtoi(strsplit(scan(,''),'\\D')[[1]]))
1: a1wAD5qw45REs5Fw4eRQR33wqe4WE
2: 
Read 1 item
[1] 97
```
Edit: Replaced `[^0-9]` with `\\D`.
[Answer]
# [Factor](https://factorcode.org) + `math.unicode sorting.human`, 36 bytes
```
[ find-numbers [ real? ] filter Σ ]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=JYq7asNAEEX7-Yop0lposdaEpAgCyyZNwApGhXEx0Y5igbXSvlhMyEe4TiMIzuek99_koebewz3346uh2vd2vJ63z49P6zvsyB_QsQmsa3boeutb_ZocQkf6XyZBt3WvGAfL3p8G22qPJuI9mPgGBClIEClQmoMgAeIvMkVuUxULSS53UuUkVbUEEjFfShMzWRZOrmLG5aacz6PhrCrg_RJ8M7u93uywabWa6dC9sHW4Q8t0fMD973z0bPH7E_fT99LRgMnE4zj1Dw)
```
                  ! "11a1"
find-numbers      ! { "" 11 "a" 1 }
[ real? ] filter  ! { 11 1 }
Σ                 ! 12
```
[Answer]
## PowerShell, ~~28~~ 26 bytes
```
$args-replace"\D",'+0'|iex
```
Takes input `$args` then does a regex `-replace` to swap the letters with `+0`, then pipes that to `iex` (short for `Invoke-Expression` and similar to `eval`).
```
PS C:\Tools\Scripts\golfing> .\filter-out-and-add-up.ps1 'a1wAD5qw45REs5Fw4eRQR33wqe4WE'
97
```
---
**Alternatively**
If you're OK with some extraneous output, you can do the following, also at ~~28~~ 26 bytes:
```
$args-split"\D"|measure -s
```
This will take the input string `$args` and `-split` it into an array-of-strings on the non-numbers (removing them in the process). For example, `1a2b33` would turn into `['1','2','33']`. We pipe that to `Measure-Object` with the `-Sum` parameter. Output would be like the below:
```
PS C:\Tools\Scripts\golfing> .\filter-out-and-add-up.ps1 'a1wAD5qw45REs5Fw4eRQR33wqe4WE'
Count    : 21
Average  : 
Sum      : 97
Maximum  : 
Minimum  : 
Property : 
```
Edit -- durr, don't need the `[ ]` in the regex since I'm no longer specifying a list of possible matches ... 
[Answer]
# Gema, 39 characters
```
<D>=@set{s;@add{${s;};$0}}
?=
\Z=${s;0}
```
Sample run:
```
bash-4.3$ gema '<D>=@set{s;@add{${s;};$0}};?=;\Z=${s;0}' <<< 'a1wAD5qw45REs5Fw4eRQR33wqe4WE'
```
[Answer]
## Seriously, 13 bytes
```
,ú;û+@s`≈`MΣl
```
[Try it online!](http://seriously.tryitonline.net/#code=LMO6O8O7K0BzYOKJiGBNzqNs&input=ImExd0FENXF3NDVSRXM1Rnc0ZVJRUjMzd3FlNFdFIg)
Explanation:
```
,ú;û+@s`≈`MΣl
,              push input
 ú;û+          push "abc...zABC...Z" (uppercase and lowercase English letters)
     @s        split on letters
       `≈`M    convert to ints
           Σ   sum
            l  length (does nothing to an integer, pushes 0 if an empty list is left, in the case where the string is all letters)
```
[Answer]
# Java, 70 bytes
```
s->{int n=0;for(String i:s.split("\\D+"))n+=Long.valueOf(i);return n;}
```
[Answer]
# TI-Basic, 106 bytes
Works on TI-83/84 calculators!
```
Input Str1
"{0,→Str2
Str1+"N0→Str1
For(I,1,length(Ans
sub(Str1,I,1
If inString("0123456789",Ans
Then
Str2+Ans→Str2
Else
If ","≠sub(Str2,length(Str2),1
Str2+","→Str2
End
End
sum(expr(Ans
```
[Answer]
# Clojure/ClojureScript, 35 bytes
```
#(apply +(map int(re-seq #"\d+"%)))
```
[Answer]
# R, 50 bytes
Requires having `gsubfn` installed
```
sum(gsubfn::strapply(scan(,''),'\\d+',strtoi)[[1]])
```
Uses `strtoi` to coerce to numeric
[Answer]
# Ruby 45 bytes
```
$*[0].split(/[a-z]/i).map(&:to_i).inject 0,:+
```
(First attempt at work, will revisit this)
[Answer]
# POSIX sh + tr + dc, 27 25 bytes
```
dc -e "0d`tr -sc 0-9 +`p"
```
Converts any run of non-digits (including the terminating newline) to `+` operator, pushes two zeros onto the stack (in case input begins with non-digit), adds them all and prints the result. There may be an extra zero remaining at bottom of stack, but we don't care about that.
[Answer]
## Lua, 51 Bytes
Pretty short for once! Even shorter than Java! The input must be a command-line argument for it to work.
```
a=0 arg[1]:gsub("%d+",function(c)a=a+c end)print(a)
```
### Ungolfed
```
a=0                 -- Initialize the sum at 0
arg[1]:gsub("%d+",  -- capture each group of digits in the string
  function(c)       -- and apply an anonymous function to each of them
  a=a+c             -- sums a with the latest group captured
end)               
print(a)            -- output a
```
]