Extract characters that differ between two strings

后端 未结 6 1960
小蘑菇
小蘑菇 2020-12-03 08:09

I have used adist to calculate the number of characters that differ between two strings:

a <- \"Happy day\"
b <- \"Tappy Pay\"
adist(a,b)          


        
6条回答
  •  生来不讨喜
    2020-12-03 08:53

    Not really proud of this, but it seems to do the job:

    sapply(setdiff(utf8ToInt(a), utf8ToInt(b)), intToUtf8)
    

    Results:

    [1] "H" "d"
    

提交回复
热议问题