Extract (parse) Amount And Description From BIZ (Transaction) Sms
I am doing below steps. match sms with regex if contains specified keyword then get values from sms body like amount,description (reason of transaction), Account number(if ATM wit
Solution 1:
For finding out amount from bank transaction message.
(?i)(?:(?:RS|INR|MRP)\.?\s?)(\d+(:?\,\d+)?(\,\d+)?(\.\d{1,2})?)
For finding out merchant name from bank transaction message.
(?i)(?:\sat\s|in\*)([A-Za-z0-9]*\s?-?\s?[A-Za-z0-9]*\s?-?\.?)
For finding out card name(debit/credit card) from bank transaction message.
(?i)(?:\smade on|ur|made a\s|in\*)([A-Za-z]*\s?-?\s[A-Za-z]*\s?-?\s[A-Za-z]*\s?-?)
Solution 2:
In python following Regex can be helpful.
For finding amount in bank messages
[rR][sS]\.?\s[,\d]+\.?\d{0,2}|[iI][nN][rR]\.?\s*[,\d]+\.?\d{0,2}
For finding A/C no
[0-9]*[Xx\*]*[0-9]*[Xx\*]+[0-9]{3,}
Solution 3:
The following two regular expressions helped in finding amount from most of the bank transactions(HDFC, ICICI, ING, KOTAK, SBI, CANARA, PNB):
[Ii][Nn][Rr](\\s*.\\s*\\d*)
[rR][sS](\\s*.\\s*\\d*)
Please comment if you have figured out much better expressions than the above.
Solution 4:
To detect any transactional message in android :
"(?=.*[Aa]ccount.*|.*[Aa]/[Cc].*|.*[Aa][Cc][Cc][Tt].*|.*[Cc][Aa][Rr][Dd].*)(?=.*[Cc]redit.*|.*[Dd]ebit.*)(?=.*[Ii][Nn][Rr].*|.*[Rr][Ss].*)"
tested on several bank messages
Solution 5:
Please check https://github.com/minimal-scouser/trny
Usage:
import { getTransactionInfo } from "trny";
const message = "Your a/c XX0413 is debited on 15/12/2020 by INR 3,211.00 towards purchase. Avl Bal: INR 5,603.54.";
const info = getTransactionInfo(message);
/*
info = {
account: {
type: "account",
no: "0413"
},
balance: "5603.54",
money: "3211.00",
typeOfTransaction: "debited"
}
*/
It also has methods like
This needs more testing but see if this solves your problem.
Post a Comment for "Extract (parse) Amount And Description From BIZ (Transaction) Sms"