Hello Monks,
I have the following subrutine to highlight all instances of a given word in a text widgets (this process is repeated x-times for the x-words I want to highlight. I use a regex in order to delimit the boundary of the words (only entire words should be highlighted). It works fine, until I try to add the -nocase flag...and here lies my problem
highlightText($TextWidget, \$term, 'selectedTerm', 'regexp'); sub highlightText { my($w, $string, $tag, $kind) = @_; my $stringw = $$string; return unless ref($string) && length($$string); my($current, $length) = ('1.0', 0); $stringw = qr/\b\Q$stringw\E\b/;#creating regex while (1) { $current = $w->search(-count => \$length, "-$kind", "-nocase", $st +ringw, $current, 'end');#here I the -nocase causes an issue last if not $current; $w->tagAdd($tag, $current, "$current + $length char"); $current = $w->index("$current + $length char"); } }
If I call $w->search without -nocase, my script works fine
In reply to Perl tk text -nocase by IB2017
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |