Last active
June 23, 2024 14:50
-
-
Save alexalannunes/701174f855da6ec849846909daec7730 to your computer and use it in GitHub Desktop.
extract bills from nubank
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
` | |
15 MAI Picpay *Enel Distribu - Parcela 4/5 R$ 26,46 | |
21 MAI Brisanet*Internet R$ 94,99 | |
22 MAI Pagamento em 22 MAI -R$ 1.160,77 | |
22 MAI Saldo restante da fatura anterior R$ 0,00 | |
22 MAI Saldo restante da fatura anterior R$ 0,00 | |
24 MAI Mercadinho e Hortifrut R$ 4,50 | |
24 MAI Angela Maria Morais S R$ 14,36 | |
24 MAI Mercantil Mundinho R$ 9,61 | |
24 MAI Google Adobe Inc R$ 7,99 | |
24 MAI Leila Carneiro Matias R$ 5,00 | |
25 MAI Mercantil Mundinho R$ 22,38 | |
25 MAI Mercantil Mundinho R$ 8,47 | |
25 MAI Pag*Mariamarleide R$ 22,00 | |
`.split('\n').filter(s => !!s).map(line => { | |
const dateReg = /\d{2}\s[A-Z]{3}/; | |
const descReg = /.+?(?=\sR\$\s?\d+,\d+)/; | |
const priceReg = /R\$\s?\d+,\d+/; | |
const dateMatch = line.match(dateReg); | |
const descMatch = line.match(descReg); | |
const priceMatch = line.match(priceReg); | |
const date = dateMatch ? dateMatch[0] : ''; | |
const desc = descMatch ? descMatch[0].trim() : ''; | |
const price = priceMatch ? priceMatch[0] : ''; | |
return `${date}, ${desc}, ${price}`; | |
}).join('\n'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment