我需要这个正则表达式的帮助。我得到一个如下所示的字符串。我想要类似的东西
服务器名称:AdminServer RUNNING
服务器名称:ServicesServer1 RUNNING
$rv="xxx ServerName: AdminServer RUNNING xxxx ServerName: ServicesServer1 RUNNING xxx"
$rv -replace ".*(ServerName: [A-Za-z0-9]*.*[RUNNING|SHUTDOWN])",'$1'
ServerName: ServicesServer1 RUNNING xxx
以我现在所拥有的,我只能得到最后一场比赛?
编辑:
$rv="xxx ServerName: AdminServer RUNNING xxxx ServerName: ServicesServer1 RUNNING
$rv -replace ".*(ServerName: [A-Za-z0-9]*.*RUNNING|SHUTDOWN)",'$1'
给
ServerName: ServicesServer1 RUNNING xxx
不是
ServerName: AdminServer RUNNING
ServerName: ServicesServer1 RUNNING
EDIT2:原来我已经过度简化了。字符串看起来更像这样:
$rv='XXX rtification Authority - G3,OU=(c) 2008 GeoTrust Inc. - For authorized use only,O=GeoTrust Inc.,C=US". The loading of the trusted certificate list raised a certificate parsing exception PKIX: Unsupported OID in the AlgorithmIdentifier object: 1.2.840.113549.1.1.11.>
Successfully Connected to Node Manager.
ServerName: SasTTpcAdminServer
RUNNING
Successfully disconnected from Node Manager.
Connecting to Node Manager ...
Successfully Connected to Node Manager.
ServerName: XXXServicesServer1
RUNNING
Successfully disconnected from Node Manager.'