DD
DevDash

Regex for Indian PIN Code

Regex Pattern

^[1-9][0-9]{5}$

6-digit Indian PIN code

Quick Answer

The regex pattern for indian pin code is `^[1-9][0-9]{5}$`. 6-digit Indian PIN code. This works in JavaScript, Python, Ruby, PHP, Java, and most regex engines that support PCRE syntax.

Test Examples

InputResult
110001✓ Matches
560001✓ Matches
400001✓ Matches
012345✗ No match
1234567✗ No match
12345✗ No match

Code Examples

javascript

const regex = /^[1-9][0-9]{5}$/;
const isValid = regex.test(value);

python

import re
pattern = r'^[1-9][0-9]{5}$'
if re.match(pattern, value):
    print("valid")

ruby

pattern = /^[1-9][0-9]{5}$/
if value =~ pattern
  puts "valid"
end

php

if (preg_match('/^[1-9][0-9]{5}$/', $value)) {
    echo "valid";
}

java

String pattern = "^[1-9][0-9]{5}$";
boolean isValid = value.matches(pattern);

Frequently Asked Questions

Related Regex Patterns

Want API access + no ads? Pro coming soon.