I'm looking for a regex to match the following pattern:
--header--
any text -pre-
any text -/pre-
-pre-
any text -/pre-
For example: the following text
--comment--
list of comments
-pre-
comment 1
-/pre-
-pre-
comment 2
-/pre-
--Answers--
list of Answers
-pre-
Answer 1
-/pre-
-pre-
Answer 2
-/pre-
should be returned as following when apply the regex:
Array
(
[comments] => Array
(
[0] => comment 1
[1] => comment 2
)
[answers] => Array
(
[0] => answer 1
[1] => answer 2
)
)
I tried the following regex --(.*?)--.*?(-pre-(.*?)-\/pre-)+
but it only match comment 1
and answer 1
Example Code: https://regex101.com/r/59OKzs/1