I have the working implementation for this as follows:
if contains($emailAddress, '@') then
substring($emailAddress, 0, find($emailAddress, '@'))
else
''
I think this should work for %40 as well. The contains check is important, as you will get exceptions otherwise.