gpt4 book ai didi

regex - bash - 提取字符串的一部分

转载 作者:行者123 更新时间:2023-11-29 09:39:43 25 4
gpt4 key购买 nike

我有一个类似这样的字符串

xsd:import schemaLocation="AppointmentManagementService.xsd6.xsd" namespace=

我想从中提取以下内容:

AppointmentManagementService.xsd6.xsd

我尝试过使用正则表达式、bash 和 sed,但没有成功。有人可以帮我解决这个问题吗?

我使用的正则表达式是这样的:

/AppointmentManagementService.xsd\d{1,2}.xsd/g

最佳答案

你的字符串是:

nampt@nampt-desktop:$ cat 1
xsd:import schemaLocation="AppointmentManagementService.xsd6.xsd" namespace=

用 awk 试试:

cat 1 | awk -F "\"" '{print $2}'

输出:

AppointmentManagementService.xsd6.xsd

关于regex - bash - 提取字符串的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38427311/

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