Powershell get content between quotation marks -


i getting output this

fila 28:   nombre del solicitante: "contoso\x000000"  fila 29:   nombre del solicitante: "contoso\e000000"  fila 30:   nombre del solicitante: "contoso\x111111" 

and need filter out content inside quotation marks please

another, possibly more intuitive, solution using regex -match , -replace

$text = 'nombre del solicitante: "contoso\x111111"'  $regex = '\s*nombre del solicitante: "([^"]+)"\s*' @($text) -match $regex -replace $regex,'$1' 

as one-liner:

@(<command>) -match ''nombre del solicitante:' -replace '.*"(.+)".*','$1' 

wrapping command output in @() make sure array, if command returns 1 line, -match operator works filter instead of boolean true/false test.

@jnk - testing array (that's command ouput going produce) ?

$text =  (@' fila 28:   nombre del solicitante: "contoso\x000000"  fila 29:   nombre del solicitante: "contoso\e000000"  fila 30:   nombre del solicitante: "contoso\x111111" '@).split("`n")   $regex = '\s*nombre del solicitante: "([^"]+)"\s*' @($text) -match $regex -replace $regex,'$1'   contoso\x000000 contoso\e000000 contoso\x111111 

edit - account name, without domain part:

$regex = '\s*nombre del solicitante: ".+?\\([^"]+)"\s*' 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -