Skip to content

LCS #3

@andrewallenbruce

Description

@andrewallenbruce

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 = "")
}

Originally posted by @andrewallenbruce in andrewallenbruce/northstar#12 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions