Converting a trigram into a bigram

My code is trying to convert a trigram into a bigram by dropping the first word in the trigram.
x <-"get_out_of_here"
I would like to have "out_of_here". I type in

str_replace(x,"^ .", "")
[1] "get_out_of_here"
Nothing has happened, so I tried leaving out the quotes
str_replace(x,^ .
, "")
Error: unexpected '^' in "str_replace(x,^"
How to fix this?

I look for characters that are not _ and then a _ and replace all of that with an empty string.

str_replace("get_out_of_here", "^[^_]+_", "")
[1] "out_of_here"
1 Like

Thank you! It worked!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.