查找数组中匹配的字符(串)的位置

来源:互联网 发布:华为端口应用acl 编辑:程序博客网 时间:2024/06/05 19:55
var StringValue = "Lorem ipsum dolor sit amet, consemctoretur elit";var posotions = new Array();var pos = StringValue.indexOf("em");while(pos > -1){posotions.push(pos);pos = StringValue.indexOf("em", pos+1);}alert(posotions); // 3,32

原创粉丝点击