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,895
  • 11
  • 56
  • 94

1 Answers1

1

Allow leading and trailing whitespaces:

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

Demo

mrzasa
  • 22,895
  • 11
  • 56
  • 94