1
var lochash = "#http://www.thepresidiumschool.com/news_image/102%20NRD_7420.jpg&lg=1&slide=0";
我想要的.jpg由JavaScript
var lochash = "#http://www.thepresidiumschool.com/news_image/102%20NRD_7420.jpg&lg=1&slide=0";
我想要的.jpg由JavaScript
可以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);
可以使用replace()
替換「JPG *」和其後的內容只有「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);