How to get all the numbers in a similar record: string(1,-2,5*(4-2)) ?

I tried this: re.sub("([+-]?\d+(?:\.\d+)?)","found",s) , but the entry ignores brackets.

So how to get all the positive, negative and numbers in brackets between string() .

  • [-]?\d+ works this way, or do we need to distinguish them somehow by parentheses? - slippyk
  • @slippyk is a snag, if there are more numbers (outside the parentheses), then they are also. I only need numbers in brackets. - jcommander
  • re.findall('[-]?\d+', re.findall('\(([^)]+\(?)*[^(]+\)', s)[0]) . One expression does not it turned out - slippyk

0