返回包含给定子字符串的字符串的所有位置

时间:2015-12-05 01:11:30

标签: r string

我有一组像这样的字符串

[[1]]

[1] "The quick brown fox jumped over the sleeping lazy dog"

[2] "The fox quickly turned around"

[3] "The sun rises every day"

[4] "Be quick on your feet"

我想返回一个包含子字符串的所有字符串位置的向量"快速"

结果应为

pos

[1]    1    4

我试过了

pmatch("quick", x, nomatch = NA_integer_, duplicates.ok = TRUE)

但返回NA值。

0 个答案:

没有答案