gpt4 book ai didi

javascript - 如何在extjs中使用href.replace

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

如何在extjs中使用href.replace

这是我的样本:

'iconCls': 'icon_' + href.replace(/[^.]+\./, '')

href= http://localhost:1649/SFM/Default.aspx#/SFM/config/release_history.png

现在我想获取文本“release_history.png”,我如何获取它。

谢谢

最佳答案

如果您只想要文件名,可能更容易做到:

var href = "http://localhost:1649/SFM/Default.aspx#/SFM/config/release_history.png";
var iconCls = 'icon_' + href.split('/').pop();

更新

要获取不带扩展名的文件名,您可以执行类似的操作:

var filename = "release_history.png";
var without_ext = filename.split('.');

// Get rid of the extension
without_ext.pop()

// Join the filename back together, in case
// there were any other periods in the filename
// and to get a string
without_ext = without_ext.join('.')

关于javascript - 如何在extjs中使用href.replace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5592652/

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