code:
var imgurl : String = http://sits/productimages/00670535922278.png?sw=350&sh=350 ; var imagesplit = imgurl.split('.(jpeg|png|jpg|gif)$/'); i am trying this code but it is not spliting into arrays. i need to split like
expected output:
imgurl
[0] : http://sits/productimages/00670535922278.png?sw=350&sh=350 ;
can anyone help me regaurding this
You can always try to do it like this;
var imgUrl = "http://sits/productimages/00670535922278.png?sw=350&sh=350;";
var splitterArray = ['.jpeg', '.png', '.jpg', '.gif'];
for (var i = 0; i < splitterArray.length; i++) {
var imgUrlArray = imgUrl.split(splitterArray[i]);
if (imgUrlArray.length > 1) {
//Do your thing here
}
}
You use a array of your extensions that will be checked, and i your string contains the extension your imgUrlArray will have a length grater than one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.