How can I have the output of the following text only show the text in the quotes (without the quotes)?
Sample text"
this is an "apple". it is red
this is an "orange". it is orange
this is an "blood orange". it is reddish
becomes:
apple
orange
blood orange
Ideally I'd like to do it in a one liner if possible. I think it's regular expression with -match but I'm not sure.
here is one way
$text='this is an "apple". it is red
this is an "orange". it is orange
this is an "blood orange". it is reddish'
$text.split("`n")|%{
$_.split('"')[1]
}
This is the winning solution
$text='this is an "apple". it is red
this is an "orange". it is orange
this is an "blood orange". it is reddish'
$text|%{$_.split('"')[1]}
Just another way using regex:
appcmd list apppool | % { [regex]::match( $_ , '(?<=")(.+)(?=")' ) } | select -expa value
or
appcmd list apppool | % { ([regex]::match( $_ , '(?<=")(.+)(?=")' )).value }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With