Distinguish matches in pyparsing
I want to parse some words and some numbers with pyparsing. Simple right. from pyparsing import * A = Word(nums).setResultsName('A') B = Word(alphas).setResultsName('B') expr = OneOrMore(A | B) result = expr.parseString("123 abc 456 7 d") print result The code above prints ['123', 'abc', '456', '7', 'd'] . So everything worked. Now I want to do some work with these parsed values. For this task, I need to know if they matched A or B . Is there a way to distinguish between these two. The only thing what I found after some research was the items method of the ParseResults class. But it only