Open andrewallenbruce opened 8 months ago
From: mirmisc
#' Get the longest common substring within two strings.
#'
#' @param x,y Strings.
#'
#' @return A string.
#'
#' @noRd
longest_common_substring <- function(x, y) {
checkmate::assert_string(x)
checkmate::assert_string(y)
if (min(nchar(x), nchar(y)) == 0) return(character(0L))
x <- strex::str_to_vec(x)
y <- strex::str_to_vec(y)
paste(qualV::LCS(x, y)$LCS, collapse = "")
}