Question:
I am trying to extract a piece of information from my email after a specific text from the output of the previous node. I am not able to get it working as desired.
Consider the following: The output of Node 1 is
16-04-2023
Dear Customer,
Thank you for banking with us.
We wish to inform you that INR 12345.67 has been debited from your A/c no. 12345678 and blah blah blah...
Sometimes, the mail may move the INR value forward, so it might look like
16-04-2023
Dear Customer,
INR 12345.67 has been debited from your A/c no. 12345678...
So, I tried writing a simple Javascript function to use on the ‘Code’ node to extract the numbers after the words ‘INR’ and give that as the output. But, the workflow is only returning an empty response. The code I tried using is:
const results = [];
for (const line of $input.all()) {
const match = String(line).match(/INR\s*(\d+(\.\d+)?)/);
const amount = match ? match[1] : null;
if (amount) {
results.push({
json: {
amount: amount
}
});
}
}
return results;
My workflow
Share the output returned by the last node
The expected output is:
12345.67
Also, can anyone please suggest what option should I choose in ‘Mode’ for this workflow?
Information on your n8n setup
- n8n version: 0.221.2
- Database: SQLite
- n8n EXECUTIONS_PROCESS: own
- Running n8n via: Docker
- Operating system: Ubuntu Server 22.04 LTS