I have a string vector data as shown below
Data
Posted by Mohit Garg on May 7, 2016
Posted by Dr. Lokesh Garg on April 8, 2018
Posted by Lokesh.G.S on June 11, 2001
Posted by Mohit.G.S. on July 23, 2005
Posted by Dr.Mohit G Kumar Saha on August 2, 2019
I have used str_extract() function as
str_extract(Data, "Posted by \\w+. \\w+ \\w+")
It generated the output as
[1] "Posted by Mohit Garg on" "Posted by Dr. Lokesh Garg" NA
[4] NA NA
I want the output should like
[1] "Posted by Mohit Garg on" "Posted by Dr. Lokesh Garg" "Posted by Lokesh.G.S"
[4] "Posted by Mohit.G.S." "Posted by Dr.Mohit G Kumar Saha"