fork download
  1. import re
  2. p = re.compile(r'([-+]?)(?:0?x)([0-9A-Fa-f]+)')
  3. test_str = u"WA2ąą-02 -7+12,7. -0x1AEfPq PP-.5P 0x1AEf +0x1AEf x0.6 words"
  4.  
  5. for x in re.findall(p, test_str):
  6. tmp = x[0] + x[1]
  7. print(int(tmp, 16))
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
-6895
6895
6895
0