I have multiple strings, and I want to extract the part that matches. In practice my strings are directories, and I need to choose where to write a file, which is the location that matches in all strings. For example, if you have a vector with three strings:
data.dir <- c("C:\\data\\files\\subset1\\", "C:\\data\\files\\subset3\\", "C:\\data\\files\\subset3\\")
...the part that matches in all strings is "C:\data\files\". How can I extract this?