-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compare individual strings #57
Labels
feature
a feature request or enhancement
Comments
rvest is a common source of such confusion, e.g. tidyverse/rvest#284 |
Need to think about And cyrillic_a <- "А"
latin_a <- "A"
cyrillic_a == latin_a |
Something like this: compare_string <- function(x, y) {
x_char <- strsplit(x, "")[[1]]
y_char <- strsplit(y, "")[[1]]
ses1 <- ses(x_char, y_char)
if (nrow(ses1) == 0 || nrow(ses1) > length(x_char)) {
return(list())
}
# If diff equivalent to every letter changing, don't highlight differences
ses2 <- ses_elementwise(x_char, y_char)
if (nrow(ses2) <= nrow(ses1)) {
return(c(x, y))
}
diff <- ses1
diff$x_start <- 1
diff$x_end <- length(x)
diff$y_start <- 1
diff$y_end <- length(y)
diff <- diff_complete(diff)
aligned <- diff_align(diff, x, y)
aligned$x[is.na(aligned$x)] <- " "
aligned$y[is.na(aligned$y)] <- " "
c(paste(aligned$x, collapse = ""), paste(aligned$y, collapse = ""))
}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Making it easier to spot (e.g.) a non-breaking space vs. a space.
The text was updated successfully, but these errors were encountered: