You're not understanding correctly, and that's probably my fault. If I retrieve the entire contents and change it there, I've messed the tags that I put in the string to mark where I want to highlight. Here's a better set of sample code. I'm demonstrating my first idea if you set $idea=0. If you go into highlightText2 and uncomment where I've said to break, you can see why I'm not using the original idea, but it does appear better here then when I originally wrote the test code on slightly different text.
use Tk; $idea = 0; $rawSequence="atggcgacgaaggccgtgtgcgtgctgaagggcgacggcccagtgcagggcatc +atcaatttcgagcagaaggaaagtaatggaccagtgaaggtgtggggaagcattaaaggactgactgaa +ggcctgcatggattccatgttcatgagtttggagataatacagcaggctgtaccagtgcaggtcctcac +tttaatcctctatccagaaaacacggtgggccaaaggatgaagagaggcatgttggagacttgggcaat +gtgactgctgacaaagatggtgtggccgatgtgtctattgaagattctgtgatctcactctcaggagac +cattgcatcattggccgcacactggtggtccatgaaaaagcagatgacttgggcaaaggtggaaatgaa +gaaagtacaaagacaggaaacgctggaagtcgtttggcttgtggtgtaattgggatcgcccaataaaca +ttcccttggatgtagtctgaggcccct"; my $mainWindow = MainWindow->new(); if( $idea) { # Main Window $mainWindow->title("Regex Problem Example 1"); $mainWindow->minsize(qw(500 500)); #Sets Minimum Size - note lack + of comma $mainWindow->geometry('+500+200'); #Sets Position - note lack of +comma $mainWindow->optionAdd('*font'=>'Courier 10'); $ROText = $mainWindow->Scrolled('ROText', -scrollbars=>'osoe'); $formattedSequence = formatSequence($rawSequence); $ROText->Insert($formattedSequence); $ROText->pack; highlightText($ROText, "gca"); } else { # Main Window $mainWindow->title("Regex Problem Example 2"); #Sets Title $mainWindow->minsize(qw(500 500)); #Sets Minimum Size - note lack + of comma $mainWindow->geometry('+500+200'); #Sets Position - note lack of +comma $mainWindow->optionAdd('*font'=>'Courier 10'); $ROText = $mainWindow->Scrolled('ROText', -scrollbars=>'osoe'); $formattedSequence = searchAndFormatSequence($rawSequence); $ROText->Insert($formattedSequence); $ROText->pack; #This works, but I can't make Uppercase->Lowercase #without removing the tags. highlightText2($ROText, "[A-Z]+"); } MainLoop(); sub highlightText { my ($widget, $searchString) = @_; #alter search string - HOW? # Create a tag to configure the text $widget->tagConfigure('foundtag', -foreground => "white", -background => "red"); $widget->FindAll(-regex, -nocase, $searchString); if ($widget->tagRanges('sel')) { my %startfinish = $widget->tagRanges('sel'); foreach(sort keys %startfinish) { $widget->tagAdd("foundtag", $_, $startfinish{$_}); } $widget->tagRemove('sel', '1.0', 'end'); } } sub highlightText2 { my ($widget, $searchString) = @_; #alter search string - HOW? # Create a tag to configure the text $widget->tagConfigure('foundtag', -foreground => "white", -background => "red"); $widget->FindAll(-regex, -case, $searchString); if ($widget->tagRanges('sel')) { my %startfinish = $widget->tagRanges('sel'); foreach(sort keys %startfinish) { $widget->tagAdd("foundtag", $_, $startfinish{$_}); } $widget->tagRemove('sel', '1.0', 'end'); } #UNCOMMENT TO BREAK! Doesn't like a regex in the replace string #$widget->FindAndReplaceAll(-regex, -case, "G", "g"); #$widget->FindAndReplaceAll(-regex, -case, "C", "c"); #$widget->FindAndReplaceAll(-regex, -case, "A", "a"); } sub searchAndFormatSequence { #I search the sequence and change any gca in the sequence to GCA t +hen #format the sequence, the end result of which is return " 1 atggcgacga aggccgtgtg cgtgctgaag ggcgacggcc cagt +GCAggG CAtcatcaat 61 ttcgaGCAga aggaaagtaa tggaccagtg aaggtgtggg gaaGCAttaa aggac +tgact 121 gaaggcctGC Atggattcca tgttcatgag tttggagata atacaGCAgg ctgta +ccagt 181 GCAggtcctc actttaatcc tctatccaga aaacacggtg ggccaaagga tgaag +agagG 241 CAtgttggag acttggGCAa tgtgactgct gacaaagatg gtgtggccga tgtgt +ctatt 301 gaagattctg tgatctcact ctcaggagac cattGCAtca ttggccGCAc actgg +tggtc 361 catgaaaaaG CAgatgactt ggGCAaaggt ggaaatgaag aaagtacaaa gacag +gaaac 421 gctggaagtc gtttggcttg tggtgtaatt gggatcgccc aataaacatt ccctt +ggatg 481 tagtctgagg cccct"; } sub formatSequence { #I do some really neat formatting here the end result of which is. +.. return " 1 atggcgacga aggccgtgtg cgtgctgaag ggcgacggcc cagt +gcaggg catcatcaat 61 ttcgagcaga aggaaagtaa tggaccagtg aaggtgtggg gaagcattaa aggac +tgact 121 gaaggcctgc atggattcca tgttcatgag tttggagata atacagcagg ctgta +ccagt 181 gcaggtcctc actttaatcc tctatccaga aaacacggtg ggccaaagga tgaag +agagg 241 catgttggag acttgggcaa tgtgactgct gacaaagatg gtgtggccga tgtgt +ctatt 301 gaagattctg tgatctcact ctcaggagac cattgcatca ttggccgcac actgg +tggtc 361 catgaaaaag cagatgactt gggcaaaggt ggaaatgaag aaagtacaaa gacag +gaaac 421 gctggaagtc gtttggcttg tggtgtaatt gggatcgccc aataaacatt ccctt +ggatg 481 tagtctgagg cccct"; }

In reply to Re^2: Searching Formatting and Highlighting Text Problem by janusmccarthy
in thread Searching Formatting and Highlighting Text Problem by janusmccarthy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.