gpt4 book ai didi

Powershell - 只打印引号之间的文本?

转载 作者:行者123 更新时间:2023-12-02 23:05:15 25 4
gpt4 key购买 nike

如何让以下文本的输出仅显示引号中的文本(不带引号)?

示例文本”

this is an "apple". it is red
this is an "orange". it is orange
this is an "blood orange". it is reddish

变成:
apple
orange
blood orange

理想情况下,如果可能的话,我想在一个类轮中进行。我认为这是带有 -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]
}

这是获胜的解决方案
$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]}

关于Powershell - 只打印引号之间的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14568218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com