andrewallenbruce / northstar

Tidy Healthcare Revenue Integrity :compass:
https://andrewallenbruce.github.io/northstar/
Apache License 2.0
4 stars 0 forks source link

String setdiff operations #12

Open andrewallenbruce opened 8 months ago

andrewallenbruce commented 8 months ago
andrewallenbruce commented 4 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 = "")
}