library(stringr)
ex_str <- "This.is.a.string" 
str_count(ex_str, fixed('.'))