Groups | Search | Server Info | Login | Register


Groups > comp.editors > #106893

Re: Slaving away with word-counts

From Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups comp.editors
Subject Re: Slaving away with word-counts
Date 2026-04-05 12:05 +0200
Organization A noiseless patient Spider
Message-ID <10qtc5p$in2o$2@dont-email.me> (permalink)
References (9 earlier) <10qgv11$3gpu5$1@dont-email.me> <20260331211545.00006b28@yahoo.com> <10qhcjq$3l179$1@dont-email.me> <10qho9v$3p0sh$1@dont-email.me> <10qj9uv$7rq4$4@dont-email.me>

Show all headers | View raw


On 2026-04-01 16:26, DFS wrote:
> On 3/31/2026 8:19 PM, Janis Papanagnou wrote:
> 
>> Though on a second view I've asked
>> myself whether a word count could simply be determined by the
>> white-space separators. 
> 
> number of spaces (using isspace()) + 1 is the standard I would think.

This quasi-formal expression is misleading. Depending on whether you
consider leading and trailing spaces on the line or not, and whether
single spaces are expressed by that function or sequences of spaces.

A regular expression is probably better to express what a "word" is;
maybe, say, /[^[:space:]]+/ . (This implies also "words" like *$%&!,
4GL, etc., besides the examples from the original post.)

> 
>> If it's so simple I wonder what these
>> other editors do to show as reported such a broken behavior.
> 
> Microsoft Word 2003 reports 223 words.

I don't have the context available here, so I cannot tell whether MS
Word does that right or not. (My experiences with the quality of MS
products isn't that good, though. YMMV.) Vim, for example, counts it
correctly. (That's what's primarily important for me.)

Janis

Back to comp.editors | Previous | NextPrevious in thread | Find similar


Thread

Re: [OT] Slaving away with word-counts (was Re: Ruminations [...]) DFS <nospam@dfs.com> - 2026-04-01 10:26 -0400
  Re: Slaving away with word-counts Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-04-05 12:05 +0200

csiph-web