Suppose I have a type string str = "[Hi all], [this is] [an example] ". I want to break it down into several parts, each of which consists of contents within a pair. In other words, I want to capture phrases within each pair of brackets. The result should look like this:
['Hi all', 'this is', 'an example']
How can I achieve this using regex in Python?
source
share