REGEXEXTRACT returns the part of a text that matches a pattern, and when the pattern contains one pair of brackets it returns only what is inside them. For a UPI narration laid out with slashes, a pattern that skips the reference number and captures the payee name gives you the merchant in one formula.
What does a UPI narration look like?
Layouts differ by bank, so look at your own statement first. Say one bank writes narrations like this, in a made-up example:
- UPI/412345678901/Swiggy Order/swiggy@okaxis/Payment from app
- Parts, separated by slashes: the word UPI, a 12-digit reference, the payee name, the payee's UPI handle, and a note.
What is the formula?
With narrations in column B starting at B2:
- =REGEXEXTRACT(B2, "^UPI/[0-9]+/([^/]+)/")
The result for the example is Swiggy Order. The pattern, piece by piece:
| Piece | Meaning |
|---|---|
| ^ | Start of the text |
| UPI/ | The literal characters UPI and a slash |
| [0-9]+ | One or more digits, the reference number |
| / | A slash after the digits |
| ( ) | The capture group: only this part is returned |
| [^/]+ | One or more characters that are not a slash, the payee name |
| / | The slash that ends the payee name |
The capture group matters. Without brackets, REGEXEXTRACT returns the whole matched text, including UPI and the number. With brackets it returns only the bracketed part.
What if the narration uses dashes, not slashes?
Some layouts use dashes, for example UPI-SWIGGY-swiggy@okaxis-BANK-412345678901. Change the separator in the pattern: ^UPI-([^-]+)-. To handle both layouts in one column, nest the formulas so the second is tried when the first finds nothing:
- =IFERROR(REGEXEXTRACT(B2, "^UPI/[0-9]+/([^/]+)/"), IFERROR(REGEXEXTRACT(B2, "^UPI-([^-]+)-"), "Check manually"))
IFERROR catches the error REGEXEXTRACT gives when nothing matches, and shows what you put next. The last fallback, Check manually, marks rows to look at yourself. You can use the full narration instead as the fallback by replacing the text with B2.
How do I fill the whole column?
- =ARRAYFORMULA(IF(B2:B500="", "", IFERROR(REGEXEXTRACT(B2:B500, "^UPI/[0-9]+/([^/]+)/"), "Check manually")))
- Put it once in C2 and it fills down. The IF skips empty rows so you do not get a column of Check manually.
- To tidy capitals, wrap the extract with PROPER, and to remove stray spaces wrap with TRIM.
Why does it return an error or the wrong part?
- No match: the narration starts differently, such as with lowercase upi. Add (?i) at the start of the pattern to ignore case.
- A payee name containing a slash splits early and returns half the name.
- More than one bracket pair: REGEXEXTRACT then returns several columns, which can spill into neighbouring cells.
- Spaces before the text. Wrap B2 in TRIM first.
What should I do with the extracted names?
Once names sit in one column, group them with QUERY or a pivot table to see totals per merchant. Different spellings of the same shop still count separately, so a short lookup list of corrections helps. A worked check: if Swiggy Order appears with amounts 320, 450 and 275, the group total is 320 plus 450 plus 275, which is 1,045.
Can I pull out the UPI handle too?
Yes, with a second formula in the next column. The handle sits between slashes and contains an at sign, so a pattern such as /([A-Za-z0-9._-]+@[A-Za-z]+)/ captures it. For the sample it returns swiggy@okaxis. Having the handle can help tell two payees with similar names apart. Treat the handle as private information if you share the sheet, since it identifies who you paid.
When the sheet stops being enough, SpendixAI imports the statement, normalises merchant names and applies your own rules and merchant aliases, so you are not maintaining patterns for each bank.
Useful ideas start with a clearer picture of your own spending.
Explore your reports

