Learn R Programming

soundcorrs (version 0.4.0)

highlight: Highlight differences between strings.

Description

Add a prefix and a suffix to all the substrings that are different between a vector of source strings, and a target string.

Usage

highlight(source, target, affixes)

Arguments

source

[character] A vector of strings to be highlighted.

target

[character] A string to which source strings are to be compared.

affixes

[character] A vector of two strings: the first to be prepended to highlighted bits, and the second to be appended to them.

Value

[character] The highlighted strings.

Details

The effect is similar to Unix diff, only all the differences are highlighted in the same colour, and a "_" is inerted where characters are missing. To save on speed, the function does not check the arguments are correct, etc.

Examples

Run this code
# NOT RUN {
cat (soundcorrs:::highlight (c("kitten","mitten"), "sitting", c("\u001b[31m","\u001b[0m")))
# }

Run the code above in your browser using DataLab