Js calculates the number of words (the same as that calculated by word), and the number of js words

Source: Internet
Author: User

Js calculates the number of words (the same as that calculated by word), and the number of js words

Background]

Users often require a field to limit the number of words to be entered. However, js uses value. length to obtain a field that is often different from the actual number of words. Some users often complain that the number of words is not so many, but the system prompts that the number of words exceeds the limit. So I studied the word count calculation rules and wrote such a program.

[Reference Code]

// Function fnGetCpmisWords (str) {sLen = 0; try {// first press ENTER for special handling str = str. replace (/(\ r \ n + | \ s + | +)/g, "Numbers"); // process English character numbers, consecutive letters, numbers, and English symbols are considered as a word str = str. replace (/[\ x00-\ xff]/g, "m"); // merges the characters m. consecutive letters, numbers, and English symbols are considered as one word str = str. replace (/m +/g, "*"); // remove the carriage return linefeed str = str. replace (/second +/g, ""); // returns sLen = str. length;} catch (e) {}return sLen ;}

Note:

I used a special Chinese character "break" for splitting during computing, But I really cannot think of it better. If there is a good method, please let us know.



How to calculate the number of words in a Word document

Right-click the blank area in the toolbar, select custom from the shortcut menu, open the custom dialog box, and select the tool category in the Command tab, as shown in 1, then, select "word count..." in the "command" list ...", Next, drag and drop the command to the Word toolbar with the left mouse button. Then, an additional Word count (W)… will be displayed on the toolbar )..." When you need to count the number of words in the document, click it.

For 07 word, "Review"-"word Count" in the toolbar"

How to calculate word count in Word documents

Simple, tool => count

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.