comsub: Find the longest common starting substring or directory

Description Usage Arguments Value Note Author(s) Examples

Description

The function search for the longest common prefix between multiple strings.

Usage

1
comsub(data, sep = "")

Arguments

data

A vector of strings

sep

A character which is used to separate elements; default ("") is used to compare single characters; other useful alternatives are "/" (or "\\" in Windows) to find the longest common directory, or " " to compare words instead of characters.

Value

A character with the longest common initial substring

Note

Modified from a suggestion taken from stackoverflow.

Author(s)

Luigi Ranghetti, phD (2017) ranghetti.l@irea.cnr.it

Examples

1
2
3
4
5
6
strings <- c("/home/user/git/sen2r",
             "/home/user/git_data/sen2r/ex/vrt/01_translate/")

comsub(strings)

comsub(strings, sep="/")

pobsteta/theia2r documentation built on May 25, 2019, 2:21 p.m.