首页 > 解决方案 > 忽略 stringdist::extract 中 maxDist 的大小写

问题描述

我正在stringdist使用R.

对于几个选项:

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

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

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

它使用maxDist. A但是,此选项将和之间的距离计a为一。就像 和 之间的距离A一样b。我想忽略字母大小写,因为maxDist. 有谁知道怎么做?

标签: rstringdist

解决方案


您可以使用tolower和编写小写模式以忽略大小写:

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

reprex 包于 2021-11-04 创建(v2.0.1)


推荐阅读