in reply to Text markup confusion
If the highlights consist only of letters, then the easiest way to cope with this is probably to construct a regular expression from each that matches (0 or more non-letters) between each pair of letters:
my @words = (qw/ tom dick and harold /); my $pattern = join '|', map join('[^a-zA-Z]*', split //), @words; my $regexp = qr{$pattern}i; while (<>) { s{($regexp)}{~\U$1\E~}g; print; }
Beware of overlapping matches: the leftmost match will be found, so this would give for example:
To c~HAR OLD~ icky pieces of wood you need ~TO M~ake a hot fireignoring the additional match of 'dick'. Similarly, if one word is a prefix of the other, only the word earlier in the list will be found.
If you need different behaviour on such overlaps, there are other approaches depending on what precisely you want it to do.
Hugo
|
|---|