我有这样一个字符串:
phrase <- "this_is.//the_first?the_second"
因此我想根据 ?并以此作为结果
>phrase_new[1]
"this_is.//the_first?"
>phrase_new[2]
"the_second"
我试过了,但没用。请问有什么办法吗?
phrase_new <- sub("[:?:]", "", phrase)
最佳答案
如果你想按字符分割,最好使用strsplit
:
> strsplit(phrase, "?", fixed = TRUE)
[[1]]
[1] "this_is.//the_first" "the_second"
关于r - 在R中减去一个字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38825174/