by sajithw on 4/20/16, 3:58 PM with 1 comments
by dalke on 4/20/16, 4:12 PM
One option is to use the internal and undocumented sre_parse module:
>>> sre_parse.parse("[AB]C[D-F](G|H)")
[('in', [('literal', 65), ('literal', 66)]), ('literal', 67),
('in', [('range', (68, 70))]), ('subpattern', (1, [('in',
[('literal', 71), ('literal', 72)])]))]
It's been stable for 10-15 years, and the above works in 2.x and 3.x.