lcPrefix returns the longest common prefix of a vector of strings.

lcPrefix(x, ignore.case = FALSE)

Arguments

x

a vector of character strings

ignore.case

Details

The implementation adapted after https://stackoverflow.com/questions/28273716/r-implementation-for-finding-the-longest-common-starting-substrings-in-a-set-of

Value

The longest common prefix.

References

https://stackoverflow.com/questions/28273716/r-implementation-for-finding-the-longest-common-starting-substrings-in-a-set-of

See also

Examples

lcPrefix(c('abcd','abef','aqwe'))
#> [1] "a"