Simplify a Home Address

So I’m trying to simplify a physcial address, for example:
3 Fred St, Fred Town QLD 4352, Autralia - 3 Fred St, Fred Town

I’ve used the following Expression:
{{ $node[“Find New Bookings”].json.location.slice(0,$node[“Find New Bookings”].json.location.indexOf(" QLD")) }}

This works perfectly :slight_smile: UNTIL the address is already in the simplifed format in which case the final result of the expression is -1 so you end up with:

3 Fred St, Fred Tow

How can I change the expression so it doesn’t delete the last character if the " QLD" is not found?

Hey @TheRam,

What about just putting an If node first and doing an If Contains QLD > simplify else go to next step?

Oh that’s amazing!
Set … Return to normal stream.
Didn’t even know these existed… Thank you so much…

Day 3 by the way :slight_smile:

1 Like

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