Learn R Programming

PTXQC (version 1.1.2)

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)

Value

Single string - might be empty ("")

Arguments

strings

Vector of strings

Examples

Run this code
  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