I realize this question probably seems painfully simple to most regular expression masters, but reviewing similar questions has not yielded a solution.
I have a vector of e-mail addresses called email
and would like to extract the text after the final period in each one. For the sake of example,
email<-c("[email protected]", "[email protected]", "[email protected]")
I have tried:
grep("[\.][a-zA-Z]*?$", email, value=T)
This gets me the error message:
Error: '.' is an unrecognised escape in character string starting ""."`
Removing the escape character on the other hand
grep("[.][a-zA-Z]*?$", email, value=T)
returns the entire e-mail address as does:
grep("\\.[a-zA-Z]*$", email, perl=T, value=T)
I'd really appreciate help at this point.
Extract text before or after space with formula in Excel Select a blank cell, and type this formula =LEFT(A1,(FIND(" ",A1,1)-1)) (A1 is the first cell of the list you want to extract text) , and press Enter button.
If you need to extract the string after the last period (.
), try with sub
sub('.*\\.', '', email)
#[1] "com" "com"
email <- c('[email protected]', 'xxx$xxxx.com')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With