Inputs
Papaya 2 Apple 1 & 2 Orange 1, 2 & 3 Kiwi 1 - 4 Banana1-4 Breadfruit
Desired Outputs
Papaya 2 Apple 1 Apple 2 Orange 1 Orange 2 Orange 3 Kiwi 1 Kiwi 2 Kiwi 3 Kiwi 4 Banana 1 Banana 2 Banana 3 Banana 4 Breadfruit
How can I do this? My thinking is a combination of Regex to detect the presence of these differing suffices and generating the missing numbers where necessary.
The language in question is CloverETL’s CTL. Using their Normalizer component to perform some data cleanup. However, I’ll take any language…translation is easy.
The last part can be matched by
(?:\d+, )*\d+ & \d+$. Though you may wanna replace the spaces with\s+. Once you have the matching string, splitting it by[,&\s]+will give you each number.Actually, if you use
^(\D+) ((?:\d+, )*\d+ & \d+)$, matching should return a list like [“the first part”, “the numbers”]. So you get everything. Split the second string, and there ya go.