Given the following string:
Test <- c("123 - Test1", "1234 - Test2", "123 - 45 - Test3")
When I use gsub
as below with very basic regex
gsub(".*- ", "", Test)
I get the following output:
"Test1" "Test2" "Test3"
How can I change my regex to only substitute up until the first -
to get the following result:
"Test1" "Test2" "45 - Test3"
I know regex is 'greedy' so I am looking for a way to overcome this greediness.