n8n LabAdvanced
Extract an Email from Text with Regex in n8n
Leads reply in free text. Extract their email address to create a CRM contact.
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:
{
"text": "Hi, please contact me at [email protected] tomorrow"
}
$json.text.match(
)[0]
βοΈ Your expression is executed against test data β any correct solution passes. +30 XP
β Solution & explanation
$json.text.match(/[\w.+-]+@[\w-]+\.[\w.]+/)[0]
Output: [email protected]
match(regex) returns an array of matches, and [0] takes the first. [\w.+-]+ matches the username, @[\w-]+ the domain, and \.[\w.]+ the extension.π‘ Pro tip: n8n has a shortcut for this exact job: $json.text.extractEmail().
Also accepted: /\S+@\S+\.\S+/