I have the following row vector:
x = c("Breakfast Sandwich 12.6 - 18.4oz 4 - 8ct",
"Buffalo Wing 7.6 - 10 oz",
"Asstd Cafe Appetizer 8 - 20",
"16in Extra Lrg Pepperoni 45.5oz")
I need to move the size to the beginning of the line, but I cannot create the correct regex
call for it. If more than one combination is found, move only the last combination. The moved part will always be preceded by a letter and a space. The desired result will be:
"4 - 8ct Breakfast Sandwich 12.6 - 18.4oz",
"7.6 - 10 oz Buffalo Wing",
"8 - 20 Asstd Cafe Appetizer",
"45.5oz 16in Extra Lrg Pepperoni"
I think a non-greedy match until something like that is found [a-z] [0-9].*?
? Or can it be used instead split
? Could you help me? Thank you in advance!
Btw, if for all test cases there is no one-step solution, a series of individual ones gsub
will work.