I’m trying to standardize some inbound data in an Architect flow. The source system is pushing phone numbers as raw E.164 strings like +15551234567, but the downstream system needs them formatted as (555) 123-4567.
I figured I could handle this right in the Data Action mapping using an expression with regexReplace. The goal is to strip the +1 and then inject the parentheses and dashes.
Here is the expression I’ve built:
regexReplace(${interaction.phoneNumber}, "^(\\+1?)(\\d{3})(\\d{3})(\\d{4})$", "($2) $3-$4")
When I test this in the Architect expression builder, it seems to parse correctly. No red squiggly lines. But when I run the flow with a test contact, the output variable is always null or just empty. If I use a simpler regex like replace(${interaction.phoneNumber}, "+", ""), it works fine.
I suspect the escaping of the parentheses or the backslashes is getting mangled somewhere between the JSON payload and the expression engine. I’ve tried double-escaping the backslashes (\\) and also single-escaping (\), but neither works.
Has anyone got a working regexReplace string for this specific format? I’d rather not spin up a separate external webhook just to format a string, that feels like overkill for something this simple.