Architect expression for phone number formatting

Trying to format a phone number string in Architect. The input is +1XXXXXXXXXX and the target format is (XXX) XXX-XXXX. I’ve been staring at the documentation for a while now. The standard string functions seem limited for this specific pattern. Can someone share the exact expression? I’d rather not spin up a custom microservice just to handle this regex replacement logic.

Watch out for leading spaces in that input. The Replace function won’t match if the string has hidden whitespace, which happens often with web form inputs. This expression strips spaces first, then formats it correctly:

Replace(Replace(Trim(PhoneNumber), " ", ""), "(\d{3})(\d{3})(\d{4})", "($1) $2-$3")