match.groups()
line = 'Dear   Tina    Buy  10 of A1~A10, cost 100 dollars'
match = re.search(
    '\\s+(?P<name>\\w+)\\D*(?P<num>\\d+)\\sof\\s(?P<item>[^,]+)(?:,\\D+)?(?P<costs>\\d+)?'
    , line)
match.groups()
Grouping data with a regex in Python