Question:
How can I have the output of the following text only show the text in the quotes (without the quotes)?
Sample text”
1 2 3 4 |
this is an "apple". it is red this is an "orange". it is orange this is an "blood orange". it is reddish |
becomes:
1 2 3 4 |
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.
Answer:
here is one way
1 2 3 4 5 6 7 8 |
$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
1 2 3 4 5 6 |
$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]} |