I am trying to find all the matches from a string using re in python.
my string is of the form
[Page]
# asdf
[/Page]
[Page]
# Hello
## Woo
[/Page]
and I want to find all the contents within the page tags. So currently I have tried -
page = re.compile(
r'^\[Page\]'
r'([\S\s]*)'
r'\[\/Page\]'
, re.IGNORECASE
)
But doing re.match using this expression matches the first [Page]
and the last [/Page]
. However I need all such occurrences. Eg.
m = re.match(page, my_string)
m.group(1)
# asdf
[/Page]
[Page]
# Hello
## Woo
I need to match all the Page tags.