我想替换以美元符号开头的字符串的所有元素。在这里你可以找到我的例子:
my_string <- "$AAPL $TSLA I recomend to buy $TLSA and to sell $AAPL; the price is rising to $12.56"
替换是单词"cashtag"
。
这是我想要的输出:
my_string
"cashtag cashtag I recomend to buy cashtag and to sell cashtag; the price is rising to $12.56"
我已经用str_replace_all
and试过了startsWith
。
但到目前为止,我还没有找到解决方案。
对于使用 tidyverse 包的建议解决方案,我也会感到非常高兴。