diff --git a/src/lib/Guiguts/ErrorCheck.pm b/src/lib/Guiguts/ErrorCheck.pm index 9a0b4c2b..f64a937f 100644 --- a/src/lib/Guiguts/ErrorCheck.pm +++ b/src/lib/Guiguts/ErrorCheck.pm @@ -1822,7 +1822,8 @@ sub unmatcheditemsrun { if ($matchstr) { # Should always be true, since we're only passing valid items to matching subroutine my $nest = ( defined $nestreg and $item =~ $nestreg ); my $matchidx = - ::hilitematchfind( $index, $endidx, $item, $matchstr, $reverse, $nest ); + ::hilitematchfind( $index, $endidx, $item, $matchstr, $reverse, $nest, + substr( $regexp, 0, 1 ) eq '^' ); unless ($matchidx) { # Failed to find a match my ( $row, $col ) = split( /\./, $index ); my $error = sprintf( "%d:%d - %s not matched", $row, $col, $item ); diff --git a/src/lib/Guiguts/Highlight.pm b/src/lib/Guiguts/Highlight.pm index 323b29cb..382ff6bf 100644 --- a/src/lib/Guiguts/Highlight.pm +++ b/src/lib/Guiguts/Highlight.pm @@ -618,11 +618,12 @@ sub hilitematchfind { my $match = shift; my $reverse = shift; my $nest = shift; + my $anchor = shift; # True for strings to only match if at start of line my $textwindow = $::textwindow; # Regex searches for either the tag or its match, since if nested you may find the tag # several times before finding the matches. - my $regexp = "(\Q$match\E|\Q$selection\E)"; + my $regexp = ( $anchor ? "^" : "" ) . "(\Q$match\E|\Q$selection\E)"; # If an HTML tag, don't want "