I'm trying to capture everything between two markers (START[number]
and END[number]
) where number also needs to be extracted. I need to support line breaks.
For instance the following :
START[1]
message to capture ...END[1]
must return :
- group 1 :
1
group 2 :
message to capture ...
group 3 :
1
Here is my attempt (demo):
START\[(\d+)\]((.|\n|\r)*?)END\[(\d+)\]
It doesn't work as I obtain a third group made of the last character of the message to capture and I don't know why.
Can someone may help me with this ? Thanks.