Can the length of a string be calculated in a flow?

For my flow I need the length of my string… is there any way to do this? I tried {{ length ( ‘test’ ) }} and several variations to this but no luck so far.

The better logic app has much more options, maybe this command works with that app

Can be done with
{{ size("[string]") }}

But it returns the string [6] instead of a numeric 6 ( in case the calculated length is 6 that is)

I could only solve it with use of a little Homeyscript code

The code:

// Filter the number out of the string size
var response = args[0];
const stringSize = '' + response.split("[")[1].split("]")[0];
return Number(stringSize);


Output:

Screenshot from 2024-08-10 17-22-44


Couldn’t get a numeric value out of it with Better logic, the result is a JSON, but the logic JSON extraction cards only accept string variables, not numeric ones
Screenshot from 2024-08-10 17-16-32


Source: Mathjs.org

Thanks so much… this works great!

1 Like