import re s = "[(-1,)]"res = re.search(r"-?\d+", s)if res != None: res = int(res.group(0))print(res)
Standard input is empty
-1
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!