Skip to content

Instantly share code, notes, and snippets.

@morishjs
Created July 20, 2016 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morishjs/855359dc5e14a35370eb27d99a48da7b to your computer and use it in GitHub Desktop.
Save morishjs/855359dc5e14a35370eb27d99a48da7b to your computer and use it in GitHub Desktop.
using regular expression
import re
f = open("regex_sum_300257.txt","r")
lines = f.readlines()
sum = 0
for line in lines:
line = line.rstrip()
x = re.findall('[0-9]+',line)
for number in x:
sum += int(number)
print sum
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment