You could do this with a regular expression. Here's one such way
x <- "3. abc4(). 3. efg3() a() 4.ed."
m <- gregexpr("\\d\\..*?(?=\\s*\\d\\.|$)",x, perl=T)
v <- regmatches(x,m)[[1]]
v; #[1] "3. abc4()." "3. efg3() a()" "4.ed."
So that gives a vector with each separate element. Then if you want you can combine them with a newline in between and then print that out (using cat
otherwise the newlines print as "\n")
cat(paste(v, collapse="\n"))
# 3. abc4().
# 3. efg3() a()
# 4.ed.
If you are new to regular expressions, it may look a bit crazy, but it looks for a single digit, followed by a decimal. Then it does a non greedy match, stopping when what follows is either just spaces then another digit-period combo or the end of the string.