I'm working with stringr, but the solution doesn't have to be. In the following string I want to replace all the spaces that have a letter to their left and right (i.e. first 2) with underscores.
str = 'ab cd ef 29 17 2 3'
stringr's replace_all don't seem to support substring matching (like str_match_all do by enclosing with (...)). And str_match_all doesn't replace. Grateful for suggestions.