Is there a better way to pull A and F from this: A13:F20
a="A13:F20" import re pattern = re.compile(r'\D+\d+\D+') matches = re.search(pattern, a) num = matches.group(0) print num[0] print num[len(num)-1] output
A F
note: the digits are of unknown length