Hey,
I have a question:
The rules for the arguments of str_replace_all() are not fully clear to me. Because I would like to find different patterns in a character vector, truncate the match and replace the match with the first part of the match:
For example:
(words <- c( "axapplexe", "baxanaxanaxa", "coxocoxonuxut", "froxoppylaxand"))
map(words,~str_replace_all(.x,
pattern="([aeiou]x[aeiou])",
replacement=unlist(str_split("\\1", "x"))[1])
with the result hopefully being c("apple", "banana", "coconut", "froppyland")
so i want to split the match at a certain letter and use the part before that certain letter as replacement. But this doesnt seem to work. Does anyone have a tip about this? I have also tried for example other replacements like replacement = tolower("\\1"), which also didnt work.
Thanks a lot
Cheers