I'm not big fan of regex but this time I think that there is no way to do what i want. Please see my example with real live testing: (BEGIN @\d+\b.*?ACTION_READLN ~.+?~) Consider such raw text data:
BEGIN @1011 Text
Text
ACTION_READLN ~variableName~
Text
END
BEGIN @1012
asdasd
ACTION_READLN ~someothervariable~
END
BEGIN @1013
asd
END
I was able to create regex which finds "BEGIN @(only numbers)" and "ACTION_READLN ~*~"
BEGIN @\d+|(ACTION_READLN.~.+~)
Now, I want to group first occurrence of BEGIN with first occurrence of ACTION_READLN. How i can do this?
EDIT: Expected results:
Group1:
BEGIN @1011
ACTION_READLN ~variableName~
Group2:
BEGIN @1012
ACTION_READLN ~someothervariable~