Lists - Uppercase and lowercase sensitivity and double words

Hi

quick question, im working on an ingredients UPC lookup and creating some variables containing lists of words

E.G


However two issues i have is that some ingredients are returned with capitalization and some as lower case starting letters IE water or Water, is there a way around this other than the list containing both variants of each word, IE capitalization substitution etc

The second issue is that any ingredients containing more than one word are not detected, IE “Soya Bean” where as “rice” would be ok do i need to wrap any words that contain white space ? ive tried the usual “soya bean”, and ‘soya bean’, neither appear to work. I have also tried compiling the list like this but results are the same
image

Hello,

If I am getting your first point right, you just want to proper-case all of the ingredients; Does this work for you? (you can find this block in of Text section of blocks, choose Title Case as the mode)

image

If above doesn’t work, a for loop looping through all elements, setting the current element to it’s title case version would do the job.


For your second one, can you elaborate on “not detected”? What unusual behavior are you seeing? Can you share a project link if possible? Thanks.

Thanks, sorry on point one

The API call may pull back a list of ingredients that will be EG rice, water, sugar - on the next call it may be Soy, Water, Sugar it seems my list must match the case for it to be returned - ill share the project with you via DM

Sorry being a goof looking at the API response each item has a space before the ingredient so its just me being stupid and not doing what i should be doing !

If you are getting an API response with “Soy” or “soy” and want to check for both, you can convert the response to all lowercase first using this block: Text - Thunkable Docs

And then compare that to “soy” for a match.

Thats really helpful thanks @tatiang

is there also a way around things like this
image

i have “Benzoic Acid”, in my list but as its comma deliminated it doesnt match due to the ) symbol

Ill try something like this maybe

Ive just tried the below and hasnt changed so i guess im doing it completely wrong :smiley:
image

Yes, instead of trying to reformat the JSON response to match the ingredient, I would use the Does Contain text block. So you would separate the response into a list (as you’ve already done) and then for each list item, you would use that text block to determine if a certain word or phrase is contained within it.

That way, a test for does list item contain “benzoic acid” should flag true for any of these:

benzoic acid
Benzoic Acid (assuming you’ve converted to lowercase)
preservatives (sorbic acid, benzoic acid)

Thanks @tatiang i do have these blocks already but if the response is Benzoic Acid, looks like my list of if contains have to match that case, so ive had to add both upper and lower case words of everything in the list to return true
This is my list


and this is the if matches block

Just put a [to lowercase] text block in front of the “FREEZE DRIED STRAWBERRY…” text block and it will convert all of those ingredients to lowercase before it creates a csv list from them. And the same for the JSON response… convert it to lowercase before checking for matches.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.