in reply to Re^2: Tags in TK Text widgets
in thread Tags in TK Text widgets

The behaviour doesn't need a Tk::TFrame, it stays the same using Tk::Frame, too.

Moreover, it seems nothing is highlighted if the line ending in the newline has the maximum length, which would concern me much more. Maybe indicate the newlines by something (a pilcrow ¶ maybe?).

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^4: Tags in TK Text widgets
by colintu (Acolyte) on Aug 17, 2024 at 10:32 UTC

    I tried replacing the newlines, but I'm having a problem, it doesn't do what I expect. Because I want the replace to appear in the text box I tried:

    $ts_box->FindAndReplaceAll(-regexp, -nocase, "[\n]", "%");
    which appeared to have no effect, so as a sanity check I tried:
    $ts_box->FindAndReplaceAll(-regexp, -nocase, "[+]", "%");
    which works and replaces all the '+' chars with '%' chars. What am I doing wrong to stop \n matching?

      I don't use Tk, but to me it looks like a problem of using double quotes where you should be using single quotes. eg. try $ts_box->FindAndReplaceAll(-regexp, -nocase, '[\n]', '%');

      I expect you don't need the square brackets either, FWIW.


      🦛

        Unfortunately that didn't make any difference and neither did leaving out the square brackets.

        I seem to remember there is something special about trying to match \n because matches are line based and \n is after the end of the match range or something weird like that.