Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

match more than one arguement on a line

$
0
0
I read a file and I search some specific lines that contains the word "transfered" and the CODES "ZEN" and "ROK". My script should select only the lines with these three parameters BUT the ROK should not be a star character "*".

Here an example and the condition that I wrote:

lines:

Transfered TWIST=1 ROK=TOTO ZEN=C2813310

Transfered TEST2=3 ROK=* ZEN=C2813310

Transfered CALIB=7 ROK=* ZEN=C2813310

Transfered LIKR1=9 ROK=TOTO ZEN=C2813310

My if condition in order to match the elements:

  $content = get-content "c:\test\log"

    foreach ($line in $content) {
        if ($line -match "Transfered.*ZEN=(.+?)\b.*")

My question is how to add to the same "if" condition the "ROK" parameters that it should not be equal to a "*" star.

So, at the end of the script, from the example above, I should have only these two lines where ROK is not equal to "*" :

Transfered TWIST=1 ROK=TOTO ZEN=C2813310

Transfered LIKR1=9 ROK=TOTO ZEN=C2813310

My script does also other tasks but these tasks are based no this filter that I have to apply.

Thank you in advance.

ps: I tried this one but didn't work:

if ($line -match "Transfered.*ZEN=(.+?).*ROK=(.+?)\b.*")


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>