I have a regex
edge case that I am unable to solve. I need to grep
to remove the leading period (if it exists) and the text following the last period (if it exists) from a string.
That is, given a vector:
x <- c("abc.txt", "abc.com.plist", ".abc.com")
I'd like to get the output:
[1] "abc" "abc.com" "abc"
The first two cases are solved already I obtained help in this related question. However not for the third case with leading .
I am sure it is trivial, but i'm not making the connections.