I have a string I am trying to create a regex for in order to extract everything inside the brackets. An example of such a string is as follows
[-At(A),+CarAt(B),-CarAt(A),-InCar]
The current regex I'm using is re.search(r'\[.*?\]', string)
, but this only returns -At(A),-InCar
instead of -At(A),+CarAt(B),-CarAt(A),-InCar
I am not sure why it's matching one set of parentheses in -At(A)
; I thought the regex I had would work because it would match everything between the brackets.
How can I get everything inside the brackets of my original string?