Forum Academy Marketplace Showcase Pricing Features

Create different database entries from a single input with Regex


Ambitious newbie here hoping someone can point me in the right direction!

Im trying to build an app where the user can add recipes and create shopping lists. Ideally the user can enter the ingredients for a recipe in a single multi-line input. On submit, the app should extract all the ingredients from the input and create separate database entries for each one, so they can be manipulated later (eg, added to a shopping list, mark as “bought”, change amount, etc).

This is what im doing so far:

  • Two tables: Recipes, Ingredients
  • The “Add recipe” form has one multi-line input (“ingredients”), and one invisible repeating group (“ingridients-extracted”). The data source for “ingredients-extracted” is the value of “ingredients”, extracted with Regex:

  • I’m still trying to figure out the regex, so far i’ve managed to split the single block of text into multiple ingredients by line using the expression .+(\n|$). I still need to figure out how to extract the amount (numbers at the beginning of each line), the unit (tbsp, tsp, cup, lbs, pinch, etc) and the title each ingredient and save them as separate fields in the same entry.*
  • When the user hits submit, I create a new recipe and I schedule an API workflow on the “ingredients-extracted” list.

  • The API workflow will create a new ingredient for each cell on the repeating group.

What do you think? How can I extract the info I need and save it in separate fields?
Should I be tackling this another way altogether?

Any help would be much appreciated. Thank you!