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

View source: R/fcn_misc.R

longestCommonPrefixR Documentation

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

  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"))     ## ""



PTXQC documentation built on July 26, 2023, 5:27 p.m.