この正規表現について助けが必要です。以下のような文字列を取得します。私は何かが欲しい
サーバー名: AdminServer 実行中 サーバー名
: ServicesServer1 実行中
$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.'