my $word = '#'; my $next = "1.0"; while (my $from = $t->search(-regexp, "\\b$word\\b", $next, "end")) { my $word_len = length $' + 1; print $word; print $word_len; $next = "$from + $word_len chars"; $t->tagAdd("red", $from, $next); $t->tagAdd("bold", $from, $next); }