I'm struggling in creating a regex to capture what's included between two keywords in a multi-line file.
In particular, consider the following file:
#%META
# date: 2022-08-27
# generated-by: Me
# id: 1
#%ENDS
#%BODY
....
#%ENDS
#%META
# date: 2022-08-27
# generated-by: Another Me
# id: 2
#%ENDS
#%BODY
....
#%ENDS
I wanted to parse what is included between the #%META
and the #%ENDS
keywords, if possible, without the leading #
, i.e., the desired result is to capture both:
date: 2022-08-27
generated-by: Me
id: 1
and
date: 2022-08-27
generated-by: Another Me
id: 2
I come out with following regex: (?<=#%META\n)([\S\s]*?)(?=#%ENDS\n)
.
However this is not capable to identify the two chuncks of text to be matched as well as does not remove the leading #
.
Could anyone help in that?
Thank's a lot! :)