gpt4 book ai didi

javascript - 从 URL 检索的正则表达式

转载 作者:行者123 更新时间:2023-11-28 19:24:02 25 4
gpt4 key购买 nike

/test-test-test/test.aspx

你好,

我从上面的 URL 中检索第一位有点困难。

测试-测试-测试

我尝试了这个 /[\w+|-]/g 但它也与最后一个 test.aspx 匹配。

请大家帮忙。

谢谢

最佳答案

一种方法是使用 Dom 解析器,如下所述:https://stackoverflow.com/a/13465791/970247 。然后您可以使用例如: myURL.segments; 访问 url 的各个部分。//= 数组 = ['test-test-test', 'test.aspx']

关于javascript - 从 URL 检索的正则表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28226851/

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