Trying to clean up a phone number coming from a webhook in an Architect flow. The input is standard E.164 like +15551234567 and I need it formatted as (555) 123-4567 for a downstream API call.
I’ve been messing with the replace and substring functions but can’t quite get the regex right in the expression builder.
Current attempt:
replace(upper(replace(substring(contact.phoneNumber, 2), "[0-9]{3}", "(\1)")), "[0-9]{3}", "\1")
It’s failing validation or just returning the original string. Is there a cleaner way to do this with built-in Architect functions? The docs are pretty sparse on complex string manipulation.