I have to replace " used as a unit of measure (inches) in strings that also contain characters in double quotes.
uuuu<- c('BELT, "V" 5L610, LONG 4.5" WIDE 7.5", TYPE "K"')
The vector in my data has 70k+ rows, I only need to worry about the " right after numbers.
my desired results would be - BELT, "V" 5L610, LONG 4.5IN WIDE 7.5IN, TYPE "K"
I tried gsub('\\d\"',"\\dIN",uuuu) but you know that's not going to give me the result correct result: "BELT, \"V\" 5L610, LONG 4.dIN WIDE 7.dIN, TYPE \"K\"
Then I tried grep to find the pattern and get the indices, however, that doesn't seem to reasonable since a single string in the vector could have both " as a UOM and as a quote. grep('\\d\"',uuuu,value = FALSE)
How do I retain the digit from my pattern? It should be possible in gsub?
gsub('(\\d)"', "\\1IN", uuuu)?