Home  >  Article  >  Web Front-end  >  js example of extracting the length of a certain () special string_javascript skills

js example of extracting the length of a certain () special string_javascript skills

韦小宝
韦小宝Original
2017-12-16 14:33:151559browse

The following editor will share with you an example of extracting the length of a certain ()special character string with js. It has a good reference value and I hope it will be helpful to everyone in learning js. Friends who are interested in js, please follow the editor to take a look.

The example is as follows:


// 提取特殊字符串长度(scrstr 源字符串 armstr 特殊字符)
getStrCount: function(scrstr, armstr) {
 var count = 0;
 while (scrstr.indexOf(armstr) >= 1) {
  scrstr = scrstr.replace(armstr, "")
  count++;
 }
 return count;
}


The above example of JS extracting the length of a certain () special string is all the content shared by the editor. I hope it can give you a reference, and I also hope you will support PHP more. Chinese website.

Related recommendations:

js Example of removing duplicate values ​​from two arrays_javascript skills

A brief analysis of the JS abstract factory pattern_

js implements the JD Express upward scrolling function

The above is the detailed content of js example of extracting the length of a certain () special string_javascript skills. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn