It looks like you are matching something from the output of a program or log file.
In this case, you want to combine enough so that you have confidence that you correspond to the right thing, but not so much, if the result changes a little, your program will go wrong.
Regular expressions work well in this case, for example
>>> import re
>>> mystring = "You have 15 new messages and the size is 32000"
>>> match = re.search(r"(\d+).*?messages.*?size.*?(\d+)", mystring)
>>> if not match: print "log line didn't match"
...
>>> messages, size = map(int, match.groups())
>>> messages
15
>>> size
32000