string wordstart
Gives the index of the first character of the word at an index.
string wordstart STRING INDEX
Description
Gives the index of the first character of the word that has the character at INDEX. A word is a run of letters, digits, and connectors such as _. Each other character, such as a space or a period, is a word of its own one character long.
An INDEX below 0 gives 0, and an INDEX past the end works as the last character.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| STRING | string | required | The text. |
| INDEX | index | required | The index of a character in the word. |
Returns
An index.
Examples
% string wordstart "hello world" 7
6
% string wordstart foo_bar 5
0
% string wordstart "hello world" 5
5
Errors
% string wordstart "hello world" x
bad index "x": must be integer?[+-]integer? or end?[+-]integer?
-errorcode NONE
% string wordstart a
wrong # args: should be "string wordstart string index"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1