测试字符是否在字符串中 [英] Test if characters are in a string
本文介绍了测试字符是否在字符串中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试确定一个字符串是否是另一个字符串的子集.例如:
I'm trying to determine if a string is a subset of another string. For example:
chars <- "test"
value <- "es"
如果值"作为字符串字符"的一部分出现,我想返回TRUE.在以下情况下,我想返回false:
I want to return TRUE if "value" appears as part of the string "chars". In the following scenario, I would want to return false:
chars <- "test"
value <- "et"
推荐答案
使用grepl
函数
grepl(value, chars, fixed = TRUE)
# TRUE
使用?grepl
查找更多信息.
这篇关于测试字符是否在字符串中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文