I'm looking for an efficient solution to the following problem:
a <- "TestStringA"
b <- "TeststringB"
magical_string_processing(a, b)
> [1] "Test""tring"
In essence: How do I detect identical parts of strings without knowing them pre hoc? How to do this operating from known patterns and using regular expressions is easy, but without the knowledge?
<--EDIT-->
Answers have been given and I'll explore them, but in the meantime stackoverflow
tags gave me nomenclature pointers and I explored e.g. https://stackoverflow.com/a/50705861/2103880, which leads to
a <- "TestStringA"
b <- c(paste(LETTERS, collapse = ""), "TeststringB")
stringdist::amatch(a,b, method = "lcs", maxDist = Inf)
[1] 2
The matching string is thus nicely identified, but the actual substring not extracted ...
Thank you for any pointers.