Вы можете получить массив, содержащий все, что вам нужно, используя это регулярное выражение.
Работает глобально с многострочным флагом.
(?m)(?:^(.*?):port:[ \t]*(.*)|(?!\A)\G)\s*^(\S+).*[)][ \t]*(.*)
https://regex101.com/r/ncUC0k/1
, который создает хороший массив, который вы можете просмотреть
[
[ServerA , OK , Process1 , Running],
[ , , Process2 , Running],
[ServerB , OK , Process1 , Stopped],
[ , , Process2 , Running],
[ , , Process3 , Running],
[ , , Process4 , Running],
[ , , Process5 , Running],
[ServerC , OK , Process1 , Stopped],
[ , , Process2 , Running],
[ServerD , OK , Process1 , Stopped],
]
Regex comments
(?m) # Multi-line mode
(?: # Cluster
^ # BOL
( .*? ) # (1), Server
:port:
[ \t]* # trim
( .* ) # (2), Port statis
| # or,
(?! \A ) # Not BOS
\G # Start where last match left off
) # ---------
\s* # Many whitespace
^ # BOL
( \S+ ) # (3), Process
.*
[)] # last ')'
[ \t]* # trim
( .* ) # (4), Process status