I need to take a chain of mixed Asian characters (for now, suppose only Chinese characters or Japanese kanji / hiragana / katakana) and Alphanumeric (ie Enlgish, French) and calculate them as follows:
1) counts every Asian CHARACTER as 1; 2) consider each alphanumeric word as 1;
a few examples:
株式会社 myCompany = 4 characters + 1 word = 5 total 株式会社 マ イ コ = 7 characters
My only idea so far is to use:
var wordArray=val.split(/\w+/);
and then check each element to see if its contents are alphanumeric (so read 1) or not (so take the length of the array). But I don’t feel that it’s really very smart at all, and the considered text can be up to 10,000 words, so it’s not very fast.
Ideas?
javascript text character counting
user224513
source share