How to extract pattern with regex in n8n?

Hello !

Coming from Make so i’m a little bit in trouble, i would like to extract phone numbers from an email, i have the right regex and (i think) the right code javascript but i don’t know how to make it work in n8n,

Could someone help me ?

Thanks a lot :slight_smile:

Hi @Lilian_Sevoumian, welcome to the community :tada:

This error message is indeed not very helpful from looking at your code, sorry for that.

My suggestion here would be to take a look at the example snippet n8n provides when adding a new Code node to your workflow. It returns a valid item using the n8n data structure. An example workflow using .test() would look like so:

You can also use regular expressions without writing code (beyond the expression) in the IF node: