我想清除一些從命令中獲得的數據。 問題是數據針對不同情況重複,並在多行上傳播。 我在問題結尾添加了數據。正則表達式匹配某些行
我想用自己的狀態,以抓住Domain|Private|Public
ON|OFF
一個例子輸出會是這樣
Domain OFF
Private ON
Public OFF
因爲多條線路的
和我有限的正則表達式的知識,我只能匹配一行。 有人可以幫助我這個正則表達式。
數據樣本:
Domain Profile Settings:
----------------------------------------------------------------------
State OFF
Firewall Policy BlockInbound,AllowOutbound
LocalFirewallRules N/A (GPO-store only)
LocalConSecRules N/A (GPO-store only)
InboundUserNotification Enable
RemoteManagement Enable
UnicastResponseToMulticast Enable
Logging:
LogAllowedConnections Disable
LogDroppedConnections Disable
FileName %systemroot%\system32\LogFiles\Firewall\pfirewall.log
MaxFileSize 4096
Private Profile Settings:
----------------------------------------------------------------------
State OFF
Firewall Policy BlockInbound,AllowOutbound
LocalFirewallRules N/A (GPO-store only)
LocalConSecRules N/A (GPO-store only)
InboundUserNotification Enable
RemoteManagement Enable
UnicastResponseToMulticast Enable
Logging:
LogAllowedConnections Disable
LogDroppedConnections Disable
FileName %systemroot%\system32\LogFiles\Firewall\pfirewall.log
MaxFileSize 4096
Public Profile Settings:
----------------------------------------------------------------------
State OFF
Firewall Policy BlockInbound,AllowOutbound
LocalFirewallRules N/A (GPO-store only)
LocalConSecRules N/A (GPO-store only)
InboundUserNotification Enable
RemoteManagement Enable
UnicastResponseToMulticast Enable
Logging:
LogAllowedConnections Disable
LogDroppedConnections Disable
FileName %systemroot%\system32\LogFiles\Firewall\pfirewall.log
MaxFileSize 4096
Ok.
你使用什麼語言?你有什麼嘗試? –
你使用什麼應用程序?這看起來應該很簡單,使用'awk'。 – Barmar
Powershell正則表達式-math命令。目前正在regexpal.com上測試[\ n \ r]。* State \ s *([^ \ n \ r] *)是我最近的代碼 –