I have a column with value as
\"RED LOBSTER CA04606\" or \"Red Lobster NewYork WY245\" n so on
How can I extract just the name Red Lobster or Red Lobster N
Alternative gsub version:
gsub
x <- c("RED LOBSTER CA04606","Red Lobster NewYork WY245") gsub("(.+)\\s+(.+$)","\\1",x) [1] "RED LOBSTER" "Red Lobster NewYork"
and to get the other part of the text:
gsub("(.+)\\s+(.+$)","\\2",x) [1] "CA04606" "WY245"