Regex for UPI ID (VPA)

A UPI ID, also called a virtual payment address (VPA), looks like name@handle, where the handle is the bank or app suffix such as oksbi or ybl. It resembles an email address, but the handle part has no dot. This pattern uses that difference to avoid matching ordinary emails.

The pattern

/\b[a-zA-Z0-9.\-_]{2,256}@[a-zA-Z]{2,64}\b(?!\.[a-zA-Z])/g

The tester opens with this pattern and the examples below already loaded. Nothing you type is uploaded.

How it works

[a-zA-Z0-9.\-_]{2,256}
The user part: letters, digits, dot, dash or underscore. A mobile number also works here.
@
Separator.
[a-zA-Z]{2,64}
The handle: letters only, so oksbi or ybl match but 123 does not.
(?!\.[a-zA-Z])
Negative lookahead: reject it if a domain dot follows, which means it is really an email address.

Examples

Matches

  • name@oksbi
  • john.doe@ybl
  • 9876543210@paytm
  • shop-123@upi

Does not match

  • @oksbi
  • a@b
  • name@123
  • name@bank.com

Use it in JavaScript

const re = /\b[a-zA-Z0-9.\-_]{2,256}@[a-zA-Z]{2,64}\b(?!\.[a-zA-Z])/g;

// Find every match in a block of text
const found = text.match(re);

// Validate that a whole value matches (no stray characters around it)
const exact = new RegExp('^(?:' + re.source + ')$', re.flags.replace('g', ''));
const isValid = exact.test(value);

Limits and tips

  • The pattern checks the format only. It cannot tell whether the handle is a real payment provider or the address is active.
  • Payment apps keep adding handles. Validating the shape and letting the payment provider confirm the address avoids rejecting new ones.

Frequently asked questions

How is a UPI ID different from an email address?

A UPI ID has no dot after the @ sign. An email has a domain such as example.com, so the pattern rejects names followed by a dot.

Can a UPI ID contain a phone number?

Yes. Many are a 10-digit mobile number followed by a handle, and the user part allows digits.