Is it possible to apply function in gsub
replacement phrase ? Let's say after str_to_title
we have
This Is One Hell Of A Blahblah Cake
I would like ignore certain words from the effect of str_to_title
function, so that I would have
This is one Hell of a blahblah Cake
I am aware that str_to_title has its own list of exception, but I would like to customize that list by reverting some phrase back to lowercase.
My approach at the moment is
gsub("( Is | One | BlahBlah )", tolower("\\1"), str_to_title(x))
but gsub
will not see the tolower
function. An idea how t achieve this ? How can we replace regex with a function acting on the matched string ?