Updated 2012-09-09 01:18:01 by RLE

string wordstart string charIndex

Returns the index of the first character in the word containing character charIndex of string. charIndex may be specified as for the index method. A word is considered to be any contiguous range of alphanumeric (Unicode letters or decimal digits) or underscore (Unicode connector punctuation) characters, or any single character other than these.

The point of word{start,stop} is to scan forward and backward for word boundaries. Let's look at salient examples:
  % set s "abc defgh i jklmnop"
  abc defgh i jklmnop
  % string wordstart $s 2
  % string wordstart $s 3
  % string wordstart $s 4
  % string wordstart $s 7
  % string wordstart $s 13

Clif Flynt usefully remarks that "... the idea is to match the behavior of the text widget index list, where you know the location of a character in a word (because a user clicked on it), and need to find the beginning and end."

See also: