Skip to content

difference between two strings (str_diff) #249

@ctmann

Description

@ctmann

It would be helpful to have a function that shows the difference between two strings, as:

x <- "a sample, etc"
y <- "a sample etc"

  
  str_diff <- function(x,y){
    setdiff(stringr::str_split(x[[1]], "")[[1]], 
                     str_split(y[[1]], "")[[1]] 
    )
  }
  
str_diff(x,y)

> str_diff(x,y)
[1] ","

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions