这将删除最后一个单词。我如何得到最后一个字(条纹)?
var BaseShirtURL = "Base Shirt Draped with Fabric Stripe";
BaseShirtURL = BaseShirtURL.substring(0, BaseShirtURL.lastIndexOf(" "));
alert(BaseShirtURL);
这将删除最后一个单词。我如何得到最后一个字(条纹)?
var BaseShirtURL = "Base Shirt Draped with Fabric Stripe";
BaseShirtURL = BaseShirtURL.substring(0, BaseShirtURL.lastIndexOf(" "));
alert(BaseShirtURL);
要获得最后一句话:
BaseShirtURL.split(' ').pop();
要删除最后一个单词,您可以这样做:
BaseShirtURL = BaseShirtURL.replace(/\w+$/,'');
这应该这样做:
var BaseShirtURL = "Base Shirt Draped with Fabric Stripe";
var stripe = BaseShirtURL.substring(BaseShirtURL.lastIndexOf(" ") + 1,
BaseShirtURL.length());
alert(stripe);