1
s="  afd [asd] [12 ] [a34]  [ -43 ]tt [+12]xxx"

Regex match should return [12, -43, 12]

re.findall(r'\[([+-]?\d+)]', s)

It doesn't work. I have no idea how to include whitespace

mrzasa
  • 22,227
  • 11
  • 53
  • 93

1 Answers1

1

Allow leading and trailing whitespaces:

\[\s*([+-]?\d+)\s*\]

Demo

mrzasa
  • 22,227
  • 11
  • 53
  • 93