Can you solve this fruit riddle?
apple is 2kg
apple banana mango is 2kg
apple apple apple is 6kg
banana banana banana is 6kg
If the fruits are limited to "apple", "banana", and "mango", how can we write a regex that extracts the names of the fruits at the beginning of each sentence?
I tried using this regex (https://regex101.com/r/fY8bK1/1):
^(apple|mango|banana) is (\d+)kg$
However, it only works for sentences with a single fruit. How can we modify it to extract all fruit names from a sentence?
The desired output should be:
apple, 2
apple banana mango, 2
apple apple apple, 6
banana banana banana, 6