Here is the code snippet:
Using the above code the following examples can be seen.my @quotes = qw(" '); foreach my $word (@quotes) { my ($line, @found, $char, $beg, $last, $escape); my $word_len = length $word; my $next = $start; while (my $from = $t->search(-regexp, "$word", $next, $end)) { $next = "$from + $word_len chars"; my ($good, $trash) = split(/\./, $from); my $comment = $t->search( -regexp => $Comment, "$from linestart" => "$from lineend"); my $comment2 = $t->search(-regexp => $Comment2, "$from linestart" => "$from lineend"); @found = split(//, $data[$good - 1]); $char = 0; $escape = 0; foreach my $chars (@found) { $escape = 1 if ($chars eq "\\"); $last = $good.".".($char + 1) if (($chars =~ /$word/) && ($be +g) && ($escape != 1)); $beg = $good.".".$char if (($chars =~ /$word/) && (!$beg) && + ($escape != 1)); $escape = 0 if (($escape == 1) && ($chars =~ /$word/) || ($ch +ars =~ /\w+/)); if (($beg) && ($last)) { unless($comment and $t->compare($comment, '<', $beg)) { unless($comment2 and $t->compare($comment2, '<', $beg)) + { unhighlight_range($t, $beg, $last); mark_word($t, $beg, $last, 'String'); } } undef $beg; undef $last; } $char++; } undef $beg; undef $last; } }
Ex:
"some text" not quoted 'this is'
the above example works fine but the following has issues.
Ex:
"some \"text\"" 'this is suppose to be'
Now that example does not quote the single quoted text but the following does.
Ex:
"some \"text\"" This makes it ok 'this is suppose to be'
Any ideas from looking at the code? I know it has to do with the value of $escape and whether or not $last and $beg have a value and when they get undefined but I am having trouble pinpointing it.
Oh and yes I know I need to take into account the other quoting methods such as qw() and such but I need this worked out first.
In reply to Tk $widget->search() issues? by Elijah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |