I am looking for a regular expression in R to replace number between 2 alphabetical characters. For example, replace 3 with m, like this:
Sa3plebecomesSampleSample1.3staysSample1.3- This word statys the same because 3 is not between alphabetical characters
I tried with below R code to replace 3 with m, but it's only working partially.
One issue is that if regex matches, instead of replacing the matching row, every time it is replacing the first row from col3. Not sure, what exactly missing.
df$col3[grep('[a-zA-Z][3][a-zA-Z]|[3][a-zA-Z]',df$col3)] <- gsub('[3]+', 'm', df$col3)