Find abbreviates that contain capitals or or lower case. Must have at minimum 1 letter followed by a period folowed by another letter and period. May contain additional letters and spaces.
input <- c("I want $2.33 at 2:30 p.m. to go to A.n.p.",
"She will send it A.S.A.P. (e.g. as soon as you can) said I.",
"Hello world.", "In the U. S. A.")
regmatches(input, gregexpr(rm_abbreviation, input, perl = TRUE))
## [[1]]
## [1] "p.m." "A.n.p."
##
## [[2]]
## [1] "A.S.A.P." "e.g."
##
## [[3]]
## character(0)
##
## [[4]]
## [1] "U. S. A."
gsub(rm_abbreviation, "", input, perl = TRUE)
## [1] "I want $2.33 at 2:30 to go to "
## [2] "She will send it ( as soon as you can) said I."
## [3] "Hello world."
## [4] "In the "
strsplit(input, rm_abbreviation, perl = TRUE)
## [[1]]
## [1] "I want $2.33 at 2:30 " " to go to "
##
## [[2]]
## [1] "She will send it " " ("
## [3] " as soon as you can) said I."
##
## [[3]]
## [1] "Hello world."
##
## [[4]]
## [1] "In the "