使用str_detect时如何忽略大小写? [英] How to ignore case when using str_detect?
本文介绍了使用str_detect时如何忽略大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
stringr 包提供了很好的字符串函数.
stringr package provides good string functions.
搜索字符串(忽略大小写)
To search for a string (ignoring case)
可以使用
stringr::str_detect('TOYOTA subaru',ignore.case('toyota'))
这有效但会发出警告
请使用 (fixed|coll|regex)(x, ignore_case = TRUE) 而不是 ignore.case(x)
Please use (fixed|coll|regex)(x, ignore_case = TRUE) instead of ignore.case(x)
重写它的正确方法是什么?
What is the right way of rewriting it?
推荐答案
搜索字符串必须在函数 fixed
内并且该函数具有有效的参数 ignore_case
the search string must be inside function fixed
and that function has valid parameter ignore_case
str_detect('TOYOTA subaru', fixed('toyota', ignore_case=TRUE))
这篇关于使用str_detect时如何忽略大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文