如何让以下文本的输出仅显示引号中的文本(不带引号)?
示例文本”
this is an "apple". it is red
this is an "orange". it is orange
this is an "blood orange". it is reddish
Run Code Online (Sandbox Code Playgroud)
变成:
apple
orange
blood orange
Run Code Online (Sandbox Code Playgroud)
理想情况下,如果可能的话,我想在一个班轮中进行。我认为这是带有 -match 的正则表达式,但我不确定。
这是一种方法
$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]
}
Run Code Online (Sandbox Code Playgroud)
这是获胜的解决方案
$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]}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12927 次 |
| 最近记录: |