IISログで特定の文字列をselect-string
検索し、上の2行と下の1行を返すがあります。
結果は次のようになります。
2012-06-15 18:26:09 98.138.206.39 OutboundConnectionResponse SMTPSVC1 WEB10 - 25 - - 220+mta1083.sbc.mail.ne1.yahoo.com+ESMTP+YSmtp+service+ready 0 0 60 0 218 SMTP - - - -
2012-06-15 18:26:09 98.138.206.39 OutboundConnectionCommand SMTPSVC1 WEB10 - 25 EHLO - WEB10.DOMAIN>COM 0 0 4 0 218 SMTP - - - -
> 2012-06-15 18:26:09 74.125.244.10 OutboundConnectionResponse SMTPSVC1 WEB10 - 25 - - 550+IP+Authorization+check+failed+-+psmtp 0 0 41 0 218 SMTP - - - -
2012-06-15 18:26:09 74.125.244.10 OutboundConnectionCommand SMTPSVC1 WEB10 - 25 RSET - - 0 0 4 0 218 SMTP - - - -
3行目は、一致し>
た行であることを示すことで始まることに注意してください。select-string
に置き換えようとしています-replace
が、置き換えが機能しないようです。>
< font color="red">$1< /font>
これが私のコードです:
$results = $results -replace "(^> )(.*)$", "< font color='red'>$1< font>"
そこにあるPowerShell正規表現の達人は、私の正規表現が一致しない理由を教えてくれますか?