1

I am using the stringdist package in R.

For several options:

grab(x, pattern, maxDist = Inf, value = FALSE, ...)

grabl(x, pattern, maxDist = Inf, ...)

extract(x, pattern, maxDist = Inf, ...)

it uses maxDist. This option however counts the distance between A and a as one. Just as the distance between A and b. I would like ignore the letter case, for maxDist. Does anyone know how?

Tom
  • 2,173
  • 1
  • 17
  • 44

1 Answers1

2

You can use tolower and write your pattern in lowercase to ignore case:

x <- "Abc"
stringdist::extract(x, pattern = "abd", maxDist = 1)
#>      [,1]
#> [1,] NA
stringdist::extract(tolower(x), pattern = "abd", maxDist = 1)
#>      [,1] 
#> [1,] "abc"

Created on 2021-11-04 by the reprex package (v2.0.1)

danlooo
  • 10,067
  • 2
  • 8
  • 22