r - 忽略 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
. 有谁知道怎么做?
解决方案
您可以使用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)
推荐阅读
- asp.net-core - ASP.NET Core 2.2 - 稍后在代码中访问 StaticFileOption RequestPath
- reactjs - React HOC 与 fetch 和 redirect 的组合导致内存泄漏
- tensorflow - 在 Google Cloud 上部署 TensorFlow 模型,接收 base64 编码字符串作为模型输入
- svelte - 如何在 Svelte 中修复“未定义 sessionStorage”?
- mysql - 为什么这条 SQL 语句不起作用?我的 MariaDB 服务器有问题吗?
- weblogic12c - 如何停止编码请求 url 的 weblogic 访问日志
- swift - 将带有日期的对象保存为用户默认值 - 日期不会相同
- google-sheets - 如何将 1 行转置为列并让另一列自动填充?
- javascript - 创建新文件夹时如何让 Google 脚本触发器自动触发(手动工作)
- git - 如何为分支优化 Jenkins 工作区