Hey folks,
I’m trying to clean up some phone number data in an Architect flow before passing it to a downstream API. The input is coming in as standard E.164 format like +18005550199, but the external system needs it formatted as (800) 555-0199. I’ve been tinkering with the replace and substring functions in the expression builder, but chaining them together is getting messy and hard to maintain. I tried using a regex replace in a Data Action, but that adds latency I’d rather avoid if a simple expression can handle it. The current expression looks something like replace(replace(substring(input.phoneNumber, 2), '-', ''), ...) and it’s breaking when the input varies slightly.
Is there a cleaner way to handle this transformation directly in the expression field? I want to avoid writing a custom JavaScript snippet or a separate API call just for string formatting. Any examples of how to strip the +1 and insert the parentheses and dashes would be super helpful. I’ve seen some people use format functions in other tools, but I can’t find a direct equivalent in the Architect expression documentation.