ingredient editor and parser

This commit is contained in:
vabene1111
2022-04-23 19:58:35 +02:00
parent b9fb78c24d
commit 825b7b7cf9
2 changed files with 11 additions and 9 deletions

View File

@@ -221,7 +221,7 @@ class IngredientParser:
# some people/languages put amount and unit at the end of the ingredient string
# if something like this is detected move it to the beginning so the parser can handle it
if re.search(r'^([A-z])+(.)*[1-9](\d)*\s([A-z])+', ingredient):
if len(ingredient) < 1000 and re.search(r'^([A-z])+(.)*[1-9](\d)*\s([A-z])+', ingredient):
match = re.search(r'[1-9](\d)*\s([A-z])+', ingredient)
print(f'reording from {ingredient} to {ingredient[match.start():match.end()] + " " + ingredient.replace(ingredient[match.start():match.end()], "")}')
ingredient = ingredient[match.start():match.end()] + ' ' + ingredient.replace(ingredient[match.start():match.end()], '')