Why is this regex not working?
import re
i="<wx._controls.Button; proxy of <Swig Object of type 'wxButton *' at 0x2d040b0> >"
m = re.match("controls(.*)[;]", i)
if m:
print m.group(1)
It returns nothing. I am trying to get everything in between, “controls” and “;”
This solution works with other test cases however not with this one.
re.matchonly matches at the beginning of the string. You wantre.search.However, it looks like you’re evaluating the result of
repron an object to get the class name. Why not just useobj.__class__.__name__instead? On use duck typing and avoid code specific to individual classes.