Determine the length of the string

  • 2020-03-30 04:12:38
  • OfStack

Just saw the js method written before: calculate the string length (2 characters in Chinese).

Methods:

Var STR = '123 yes yes ';

Var strArr = STR. The split (");

Var count = 0;

For (strArr. Length) {* * * *}

........................... (not on the code, tired!!)

Revised:


var str = '123 is ';
var tmpStr = str.replace(/[u4e00-u9fa5]/gi,"aa");
//print
tmpStr.length


Related articles: