私はいくつかの大きなログ/ダンプをSOAP(ラップなしの1行)で持っています。最初の場合 私はそのようないくつかの単純な選択文字列を行わ:Powershellで不規則な文字列を分割する方法は?
$where = "D:\log\Test\"
$what = Get-ChildItem $where -Filter "*.txt"
$regex= "(?=<\?xml).*(Envelope>)"
$Path="d:\Log\"
$Result = "D:\Log\wynik2.log"
$string = select-string -Path $what -Pattern $regex
$string
結果は次のようである:D:\ログ
D:\log\Test\test1.txt:1:g .vI.Y....(A..P.......<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">some text1</soap:Body></soap:Envelope>
D:\log\Test\test1.txt:2:g .vJ.YiB..(...P....R..<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">some text2</soap:Body></soap:Envelope>
...
D:\log\Test\test1.txt:4000:g .vL.Yb...'...P.......<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">some text2</soap:Body></soap:Envelope>
は、どのように私は私のSOAP(例の一部ではないものをすべてをドロップすることができます\ Test \ test1.txt:4000:g .vL.Yb ... '... P .......)
ありがとうございました。この正規表現^。*(<\?xml)を取得できませんでした。 – tadamsky