I\'m trying to get the ending for email addresses (ie .net, .com, .edu, etc.) but the portion after the @ can have multiple periods.
library(stringi)
stri
A read.table + file_ext approach (not regex but pretty easy):
dat <- read.table(text=strings1, sep="@")
dat$V3 <- tools::file_ext(strings1)
dat
## V1 V2 V3
## 1 test aol.com com
## 2 test hotmail.com com
## 3 test xyz.rr.edu edu
## 4 test abc.xx.zz.net net
Here's a purely regex approach:
do.call(rbind, strsplit(strings1, "@|\\.(?=[^\\.]+$)", perl=TRUE))
## [,1] [,2] [,3]
## [1,] "test" "aol" "com"
## [2,] "test" "hotmail" "com"
## [3,] "test" "xyz.rr" "edu"
## [4,] "test" "abc.xx.zz" "net"