标签:
//js统计字符串中包含的特定字符个数
function
getPlaceholderCount(strSource) {
//统计字符串中包含{}或{xxXX}的个数
var
thisCount = 0;
strSource.replace(/\{[xX]+\}|\{\}/g,
function
(m, i) {
//m为找到的{xx}元素、i为索引
thisCount++;
});
return
thisCount;
}
标签:
原文地址:http://www.cnblogs.com/yujiangong/p/5878305.html