beetlebug▾
/

text search

Finds a pattern in the content and gives the index of the first match.

PATHNAME search ?SWITCH ...? PATTERN INDEX ?STOPINDEX?

Description

Searches from INDEX forward, or backward with -backwards, up to STOPINDEX or around the whole content. Gives the index of the start of the first match, or an empty string. The switches are:

Returns

An index, a list of indices with -all, or an empty string.

Examples

% text .sr
> .sr insert end "hello world\nline two"
> .sr search two 1.0
2.5

% text .sr2
> .sr2 insert end "Hello world"
> .sr2 search -nocase -count n WORLD 1.0
> set n
5

Errors

% text .sr3; .sr3 search
wrong # args: should be ".sr3 search ?switches? pattern index ?stopIndex?"
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also