n8n LabIntermediate
Remove Characters with replaceAll() in n8n
WhatsApp APIs need phone numbers without dashes. Clean the number before the HTTP Request node.
Live Execution Simulator
Idle
π₯
Incoming Data
βοΈ
n8n Node
π―
Next Step
> Ready. Type your expression below and click "Check Answer" to run the node.
Incoming Payload / Data:
{
"phone": "+971-50-123-4567"
}
$json.phone.
βοΈ Your expression is executed against test data β any correct solution passes. +20 XP
β Solution & explanation
$json.phone.replaceAll('-', '')
Output: +971501234567
replaceAll(search, replacement) replaces every occurrence. Plain replace('-', '') only removes the first dash β a very common bug. A regex with the g flag also works.π‘ Pro tip: Strip everything except digits and +: $json.phone.replace(/[^0-9+]/g, '').
Also accepted: replace(/-/g, '')