出於某種原因,pyparsing沒有嵌套列表我的字符串:pyparsing不是嵌套列表...爲什麼?
rank = oneOf("2 3 4 5 6 7 8 9 T J Q K A")
suit = oneOf("h c d s")
card = rank + Optional(suit)
suit_filter = oneOf("z o")
hand = card + card + Optional(suit_filter)
greater = Literal("+")
through = Literal("-")
series = hand + Optional(greater | through + hand)
series_split = Literal(",")
hand_range = series + ZeroOrMore(series_split + series)
hand_range.parseString('22+,AKo-ATo,KQz')
>> ['2', '2', '+', ',', 'A', 'K', 'o', '-', 'A', 'T', 'o', ',', 'K', 'Q', 'z']
我不知道爲什麼pyparsing沒有創建列表22+左右,AKO-ATO,和KQZ(或任何比那更深的層)。我錯過了什麼?
好的答案,只是'invRegex.py'鏈接已經死了。 – shuttle87 2015-06-23 23:29:42