I\'ve got 2 vectors:
word1 <- \"bestelling\"
word2 <- \"bestelbon\"
Now I want to find the largest common substring that starts at the
This will work for an arbitrary vector of words
words <- c('bestelling', 'bestelbon')
words.split <- strsplit(words, '')
words.split <- lapply(words.split, `length<-`, max(nchar(words)))
words.mat <- do.call(rbind, words.split)
common.substr.length <- which.max(apply(words.mat, 2, function(col) !length(unique(col)) == 1)) - 1
substr(words[1], 1, common.substr.length)
# [1] "bestel"