String operation in a microflow CHANGE activity

I would appreciate if someone could check the syntax of the following and identify where it is failing: substring($accountcode, 0, find($accountcode, '%40')) The modeler is happy with the syntax, and the "$accountcode" variable is valid. $accountcode contains an email address with the @ symbol replaced with its plain text counterpart, %40. My goal is to identify the placement of %40 in the string, extract the portion of the string from the beginning until that location, and then store that result in another attribute. I also tried it with a "-1" offset at the end of the calculation but since it didn't work at all, I don't know if that is required. Whatever is wrong with this causes the execution of the microflow to stop. Thanks.
1 answers

I have the working implementation for this as follows:

if contains($emailAddress, '@') then
    substring($emailAddress, 0, find($emailAddress, '@'))

I think this should work for %40 as well. The contains check is important, as you will get exceptions otherwise.