Regex for Indian comma format (lakh/crore)
Number in Indian grouping: 1,00,000 not 100,000.
The Indian comma format (lakh/crore) regex is ^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$ — copy it below, or open it in the explainer for a token-by-token breakdown.
The pattern
^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$
What it matches
1,00,00010,00,0001,00,00,00099,99,99,999.99
What it doesn't match
100,0001,0001,0,0001,000,000
Notes & gotchas
The Indian numbering system groups the lowest 3 digits then every 2 digits above: 1 lakh = 1,00,000; 1 crore = 1,00,00,000. Distinct from the international comma-every-3-digits format.
Code in your language
Use the explainer's Code tab to generate ready-to-paste snippets in JavaScript, Python, Java, .NET, Go, Ruby, and PHP for this pattern.
Open in explainer →Token-by-token breakdown
Every part of the pattern, left to right:
| Token | Meaning |
|---|---|
^ | start of string (or line in multiline mode) |
\d{1,2} | between 1 and 2 times: digit (0–9) |
( | start of a capturing group |
, | literal text “,” |
\d{2} | exactly 2 times: digit (0–9) |
)* | end of group, zero or more |
, | literal text “,” |
\d{3} | exactly 3 times: digit (0–9) |
( | start of a capturing group |
\. | literal “.” |
\d+ | one or more: digit (0–9) |
)? | end of group, optional (zero or one) |
$ | end of string (or line in multiline mode) |
About this pattern
India-specific identifiers are governed by various authorities (UIDAI for Aadhaar, Income Tax Dept for PAN, RBI for IFSC, GSTN for GSTIN, etc.). Regex confirms format; for definitive validation, integrate with the issuing authority's verification API.
Quick usage in different languages
This exact pattern — with the correct escaping and idioms for each language:
- JavaScript:
/^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$/.test(value) - Python:
re.match(r"^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$", value) - Java:
Pattern.compile("^\\d{1,2}(,\\d{2})*,\\d{3}(\\.\\d+)?$").matcher(value).matches() - C# / .NET:
Regex.IsMatch(value, @"^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$") - Go:
regexp.MustCompile(`^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$`).MatchString(value) - Ruby:
/^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$/.match?(value) - PHP:
preg_match('~^\d{1,2}(,\d{2})*,\d{3}(\.\d+)?$~', $value)
The explainer’s Code tab regenerates these for any pattern you paste, and the downloadable cheat sheet bundles the breakdown, all seven snippets, and the pitfalls below onto one printable page.
Common pitfalls
- Anchored to the whole string. This pattern uses ^ and $, so it requires the entire input to match. To find it inside a longer text, drop the anchors and use the global (g) flag.
- Watch for backtracking. This pattern nests quantifiers; on adversarial input that can cause exponential backtracking (ReDoS). Test with long non-matching strings, or use an RE2-based engine.
- Escape it correctly per language. In Java and JavaScript strings each backslash must be doubled (\\d); in Python, Go, and C# use raw/verbatim strings so the backslashes survive.
- Validate beyond format. Matching the format doesn't guarantee the value is real. Confirm the indian comma format (lakh/crore) against a source of truth (database, API, or checksum) where it matters.
Related patterns
More patterns in the India 🇮🇳 category:
- Indian rupee amount
- Maharashtra vehicle registration
- FSSAI license
- Delhi vehicle registration
- ESI number
- Karnataka vehicle registration
See also
Browse all 300 patterns in the library, or open this regex in the interactive explainer for a token-by-token breakdown, live testing, and code in seven languages.
Want more patterns? Browse the full library →