0

I want to validate price format which can have values as eg. ₹ 3.50L,₹ 3.50, ₹ 3.50Cr,₹ 99.50L, ₹ 3L,₹ 300.50Cr, ₹ 350Cr, ₹ 3,50,000 ,₹ 1

I have tried this Regex : ^₹ ([0-9]+(,[0-9]+)*|[0-9]+(.[0-9]+)*(L|Cr))+$ which should fail for price ₹ 3,50L but it still show as pass.

What changes I need to make

1 Answers1

0

Following regex will get your work done:

^₹ (([0-9]+\,[0-9]+)|([0-9]+[.]?[0-9]*(?:L|Cr)?))$

([0-9]+\,[0-9]+) : Will match values where ',' is used without L or Cr.

([0-9]+[.]?[0-9]*(?:L|Cr)?) : Will match values with L or Cr. Here '.' may or may not be used.

Use cases on Regex101

Dhaval Simaria
  • 1,886
  • 3
  • 28
  • 36