Version 4 of string wordstart

Updated 2005-12-22 22:20:31

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
  0
  % string wordstart $s 4
  4
  % string wordstart $s 7
  4
  % string wordstart $s 13
  12

See also:


Tcl syntax help - Category Command - Category String Processing