2017-10-30 11 views
1

"segment1"、 "segment2"などの後に続く数字を抽出しようとしています。たとえばNS1:segment1> 307000のパターンです。私はちょうど307000を持っていたいと思います。私はまだ学習しているので、私はメモ帳で正規表現を使用する簡単な方法を理解できません。以下は、私が望むもののサンプルです:Notepad ++ Regex Extract情報

/NS1:salesCredits 
    NS1:distributions 
    NS1:interfaceLineContext>TS</NS1:interfaceLineContext 
    NS1:interfaceLineAttributes 
    NS1:interfaceLineAttribute1>11111</NS1:interfaceLineAttribute1 
    NS1:interfaceLineAttribute2>TSO</NS1:interfaceLineAttribute2 
    NS1:interfaceLineAttribute3>TSO1234</NS1:interfaceLineAttribute3 
    NS1:interfaceLineAttribute4>12345678</NS1:interfaceLineAttribute4 
    /NS1:interfaceLineAttributes 
    NS1:attribute1/ 
    NS1:accountClass>REV</NS1:accountClass 
    NS1:amount>0.00</NS1:amount 
    NS1:orgId>103</NS1:orgId 
    NS1:percent>0</NS1:percent 
    NS1:segments 
    NS1:segment1>307000</NS1:segment1 
    NS1:segment2>460075</NS1:segment2 
    NS1:segment3>0000</NS1:segment3 
    NS1:segment4>321000</NS1:segment4 
    NS1:segment5>32181</NS1:segment5 
    NS1:segment6>000000</NS1:segment6 
    NS1:segment7>00000</NS1:segment7 
    /NS1:segments 
    /NS1:distributions 
    NS1:distributions 
    NS1:interfaceLineContext>TS</NS1:interfaceLineContext 
    NS1:interfaceLineAttributes 
    NS1:interfaceLineAttribute1>104009</NS1:interfaceLineAttribute1 
    NS1:interfaceLineAttribute2>TS</NS1:interfaceLineAttribute2 
    NS1:interfaceLineAttribute3>TS45678</NS1:interfaceLineAttribute3 
    NS1:interfaceLineAttribute4>9875412</NS1:interfaceLineAttribute4 
    /NS1:interfaceLineAttributes 
    NS1:attribute1/ 

この情報を抽出するための助けがあれば、どんな助力もあります。交換するメモ帳で

答えて

1

は++、元に戻してメニューを開きはCtrl +Hを打ちます。

検索:\s+NS1:segment\d+>(\d+).*|.*

置き換え:\1としてみてください動作しません$1

$1場合。

まずそれがNS1:segment\d+>(\d+).*

ために括弧の間の一致をチェックしますが、それは最初に一致しているので、Capture groupsは$ 1に割り当てされますと呼ばれます。

一致しない場合は、他のすべての行を何も置き換えないように一致するものが一致するかどうかを確認します(.*)。

307000 
460075 
0000 
00 
32181 
000000 
00000 
:あなたが提供されているサンプルを使用して

それはであなたを残します