Learn R Programming

PTXQC (version 1.0.4)

longestCommonPrefix: Get the longest common prefix from a set of strings.

Description

Input is converted to character (e.g. from factor) first.

Usage

longestCommonPrefix(strings)

Arguments

strings

Vector of strings

Value

Single string - might be empty ("")

Examples

Run this code
# NOT RUN {
  longestCommonPrefix(c("CBA.321", "CBA.77654", ""))    ## ""
  longestCommonPrefix(c("CBA.321", "CBA.77654", "CB"))  ## "CB"
  longestCommonPrefix(c("ABC.123", "ABC.456"))          ## "ABC."
  longestCommonPrefix(c("nothing", "in", "common"))     ## ""


# }

Run the code above in your browser using DataLab