Your task in this kata is to implement a function that calculates the sum of the integers inside a string. For example, in the string "The30quick20brown10f0x1203jumps914ov3r1349the102l4zy dog", the sum of the integers is 3635.

*Note: only positive integers will be tested.*

Difficulty: introductory

Starter code:

def sum_of_integers_in_string(s):
	

Solutions:
import re

def sum_of_integers_in_string(s):
    return sum(int(x) for x in re.findall(r"(\d+)", s))

import re

def sum_of_integers_in_string(s):
    return sum(map(int, re.findall("\d+", s)))

import re

def sum_of_integers_in_string(s):
  return sum(int(i) for i in re.findall('\d+', s))


def sum_of_integers_in_string(s):
    return sum(map(int, ''.join(c if c.isdigit() else ' ' for c in s).split()))

import re
def sum_of_integers_in_string(s):
    return sum([int(i) for i in re.findall(r'\d+',s)])

def sum_of_integers_in_string(s):
    che = "0123456789"
    tmp = ""
    res = []
    
    for i in range(len(s)) :
        if s[i] in che :
            tmp+=s[i]
            if i == len(s)-1 :
                res.append(int(tmp))
        elif tmp!="":
            res.append(int(tmp))
            tmp = ""
        
    return sum(res)

import re

def sum_of_integers_in_string(s):
    return sum([int(x) for x in re.findall(r'([\d]+)', s)])

import re
def sum_of_integers_in_string(s):
    return sum([int(n) for n in re.findall('\d+', s)])

import re

def sum_of_integers_in_string(s):
    return sum(map(int, re.findall(r'\d+',s)))

def sum_of_integers_in_string(s):
    for x in s: 
        if not x.isdigit(): s = s.replace(x, ' ')
    return sum(map(int, s.split()))