This article illustrates the method of the number of specific characters appearing in the data string of JS implementation. Share to everyone for your reference, specific as follows:
The number of specific characters contained in the JS statistics string
function Getplaceholdercount (strsource) {
//statistics string contains {} or {XxXX} number
var thiscount = 0;
Strsource.replace (/\{[xx]+\}|\{\}/g, function (M, i) {
//m for found {XX} element, I is index
thiscount++;
});
return thiscount;
}
PS: Here again for you to recommend a very convenient statistical tool:
Online Word Count tool:
Http://tools.jb51.net/code/zishutongji
More readers interested in JavaScript-related content can view this site: "JavaScript in the JSON Operation tips Summary", "JavaScript switching effects and techniques summary", "JavaScript Search Algorithm Skills summary", " JavaScript animation effects and tips Summary, "JavaScript Error and debugging skills Summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and Skills summary" and "JavaScript Mathematical operation Usage Summary"
I hope this article will help you with JavaScript programming.