gpt4 book ai didi

javascript - 从长字符串中提取javascript中以 "(/"开头并以 "/)"结尾的特定字符串

转载 作者:行者123 更新时间:2023-12-03 03:31:26 24 4
gpt4 key购买 nike

使用 javascript 从长字符串中提取以“(/”开头并以“/)”结尾的特定字符串。我尝试了正则表达式,但没有成功

我的字符串如下

"Dear Mr./Ms. (/Name/),​Following up for the position of (/Developer/), I’d like to inquire about the progress of your hiring decision and the status of my job application. I am very eager to (/Work/) with your company.​Thanks for your time and consideration, and I look forward to hear back from you soon.​Sincerely,(/YourName/)"

所需输出 = 姓名、开发人员、工作、您的姓名

最佳答案

您可以使用以下代码

let result =  "Dear Mr./Ms. (/Name/),​Following up for the position of (/Developer/), I’d like to inquire about the progress of your hiring decision and the status of my job application. I am very eager to (/Work/) with your company.​Thanks for your time and consideration, and I look forward to hear back from you soon.​Sincerely,(/YourName/)";

let ans = result.match(/\/\w+\//g);

ans = ans.map(e => e.replace(/\//g, ''));
console.log(ans);

关于javascript - 从长字符串中提取javascript中以 "(/"开头并以 "/)"结尾的特定字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46079384/

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