I'm trying to detect some dots (.) in my string and replace them with the same dots alongside a word, for example "." becomes ".AAA" . but there are some conditions that I want to avoid replacing:
- if there is a space and then a single character before the dot
- if the dots are between two hyphens (-)
for example, if the input is:
string <- "first. - second. - third. 4."
my desired output is:
"first.AAA - second. - third.AAA 4."
for the first condition I could figure out this:
str_replace_all("[^ [A-Z19a-z]\\.]([\\.])","\\1AAA")
but got confused when reading about look-ahead and look-behind for solving the second condition and mixing the two together.