You can use
([Unit].*)
([Diag].*(?:
.+)*)
See the regex demo
Details:
([Unit].*)
- Group 1: [Unit]
and the rest of the line
- a line feed char
([Diag].*(?:
.+)*)
- Group 2: [Diag]
, then the rest of the line and then zero or more non-empty lines.
A variation of the pattern is
(?m)^([Unit].*)
([Diag].*(?:
h*S.*)*)
See this regex demo.
Here, (?m)^
matches any start of line position and h*S.*
makes it match non-blank lines (h*
matches zero or more horizontal whitespace and S
matches any non-whitespace char). Replace h
with [p{Zs}]
or [^S
]
if not supported.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…