I have an example which is :
[Unit] =
[Diag] = Nilan zok-98
Alert danger C-00N47
[Unit] = 17B NORWAY
[Diag] = Mobari-testing-17-AB
Pair num to get 17-9881 to be testing
Class nump
[Unit] =
[Diag] = BLOC1
I want to extract this example in two part like as below :
Match 1
Group 1. [Unit] =
Group 2. [Diag] = Nilan zok-98
Alert danger C-00N47
Match 2
Group 1. [Unit] = 17B NORWAY
Group 2. [Diag] = Mobari-testing-17-AB
Pair num to get 17-9881 to be testing
Class nump
Match 3
Group 1. [Unit] =
Group 2. [Diag] = BLOC1
I was using (.*\[Unit\].*\n).*(.*\[Diag].*) to get solution, but Diag section get always first line.
You find my test regex here : https://regex101.com/r/p6nLiK/1