take numbers wherever they are

This commit is contained in:
Frédéric Péters 2012-06-05 12:57:06 +02:00
parent 42d241d89e
commit 45d30d4e13
1 changed files with 6 additions and 6 deletions

View File

@ -6,15 +6,15 @@ import tabellio.config.utils
def get_no_as_int(i):
if i:
if ' ' in i:
try:
return int(re.match('\d+', i.strip()).group())
except (ValueError, AttributeError):
return 99999
try:
return int(i.split('-')[0])
except ValueError:
return 99999
pass
try:
return re.findall('\d+', i)[0]
except IndexError:
pass
return 99999
return 0
class Cmp: