Regex to extract a shopping list product

Hey Bubbles,

I’m building a shopping list app and I’m struggling with the final extraction and could do with some help please.

Users can enter plain text e.g. 3kg of Potatoes, or 3 Potatoes, or 3 kg Potatoes, or potentially just Potatoes.

I’ve managed to extract the number, and the units, however i’m struggling to isolate Potatoes. The word “of” also needs removing if it exists.

Any ideas? is regex even the best approach for this?

Many thanks

Hey @dca82 ! If you can extract the other items, then you can always do a find a replace on the text in question removing out the extracted items. For example, if its 3kg of potatoes. You can extract out the 3kg and then do a find and replace on the entire text replacing “3kg” and common words like " of " and other variations. To then end with just the text you need. May require some messing around but could be a solution.

Hmm interesting idea… i’ll give it a shot! thanks

it works. Amazing thanks!