Could you perhaps make a little example, which reproduced the challenge you are experiencing?
Perhaps this is what you mean:
library('tidyverse')
"ACG ACTG" %>% str_replace_all(' ','')
[1] "ACGACTG"
abd then you can do:
"ACG ACTG" %>% str_replace_all(' ','') %>% str_sub(start = 2, end = 4)
[1] "CGA"
?