Needed to extract data from email recieved

Hello Every one I want to extract data from below text
“30-12-2022 Dear Abhay Daga, Thank you for using your Card no. XX06598 for INR 10000 at GOOGLESERVI on 30-12-22 00:03:37. The total credit limit on your card is INR 108000, while the available limit is”

I want to extract amount in inr "10000 "
merchant like "GOOGLESERVI "
date “30-12-22 00:03:37”

can anyone help me to extract via function

Hey, @Spinefit I usually use the split() method in a Code Node for this type of tasks.
The problem would be the reproducibility of the code, if the layout or template of the email changes, the code would break.
Here is an example

var text = item.json.text;
item.json.amount = text.split("INR")[1].split("at")[0]

Hope this helps,
:smiley:

2 Likes

Email parsing is totally dependent on format changes.
I use split (as you did), match, replace, trim functions in my parsing but always one step away from the email sender to decide to change things up !
I start with converting HTML to text and then getting rid of all the header and footer text.
Then use these functions to extract text and clean it up.

Here is my VERY CRUDE HTML to plain node

1 Like

use regex to match the INR but you need to ensure the format is the same each time

To extract the amount in INR use the following pattern:

INR \d+

To extract the merchant you can use the following pattern:

at ([^\s]+)

To extract the date you can use the following pattern:

\d{2}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}
2 Likes

Thanx Solved

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.