var lochash = "#http://www.thepresidiumschool.com/news_image/102%20NRD_7420.jpg&lg=1&slide=0";
我希望在.jpg
之后删除或替换内容答案 0 :(得分:1)
您可以使用replace()
替换' jpg *'只需' jpg'。
var lochash = "#http://www.thepresidiumschool.com/news_image/102%20NRD_7420.jpg&lg=1&slide=0";
var newlochash = lochash.replace(/jpg(.)+/,'jpg');
console.log(newlochash);

答案 1 :(得分:0)
您可以substring
删除' .jpg'。
var lochash = "#http://www.thepresidiumschool.com/news_image/102%20NRD_7420.jpg&lg=1&slide=0";
lochash = lochash.substring(0, lochash.indexOf('.jpg')+4);
console.log(lochash);