How to validate Indian Passport number using Regular Expression - GeeksforGeeks (2024)

// Java program to validate

// passport number of India

// using regular expression

import java.util.regex.*;

class GFG {

// Function to validate

// passport number of India

// using regular expression

public static boolean isValidPassportNo(String str)

{

// Regex to check valid.

// passport number of India

String regex = "^[A-PR-WY][1-9]\\d"

+ "\\s?\\d{4}[1-9]$";

// Compile the ReGex

Pattern p = Pattern.compile(regex);

// If the string is empty

// return false

if (str == null) {

return false;

}

// Find match between given string

// and regular expression

See Also
ID Type

// using Pattern.matcher()

Matcher m = p.matcher(str);

// Return if the string

// matched the ReGex

return m.matches();

}

// Driver code

public static void main(String args[])

{

// Test Case 1:

String str1 = "A21 90457";

System.out.println(isValidPassportNo(str1));

// Test Case 2:

String str2 = "A0296457";

System.out.println(isValidPassportNo(str2));

// Test Case 3:

String str3 = "Q2096453";

System.out.println(isValidPassportNo(str3));

// Test Case 4:

String str4 = "12096457";

System.out.println(isValidPassportNo(str4));

// Test Case 5:

String str5 = "A209645704";

System.out.println(isValidPassportNo(str5));

}

}

How to validate Indian Passport number using Regular Expression - GeeksforGeeks (2024)

FAQs

How to verify the passport number in India? ›

Provide Passport number & DOB Code as input, and the API will verify the details:
  1. Name of the individual.
  2. Status of the passport.
  3. Date of birth of the individual.
  4. Passport present in government database or not.

How to verify a passport is valid? ›

To verify that a U.S. passport is not fraudulent, the jurisdiction can check via USPVS that the passport number and date of birth on the passport matches the passport's electronic record, as recorded in U.S. government files.

What is the format of a passport number in India? ›

For a passport number to be considered valid in India, it must adhere to the following criteria: It should consist of eight characters. The first character must be an uppercase alphabet. The next two characters should be numbers, with the first character ranging from 1 to 9 and the second character from 0 to 9.

What are the rules for passport number validation? ›

It should be eight characters long. The first character should be an uppercase alphabet. The next two characters should be a number, but the first character should be any number from 1-9 and the second character should be any number from 0-9. It should be zero or one white space character.

Can I check my passport number online? ›

The only way to look up your passport number online is if you've saved it on a website or with a travel company, like an airline.

How to read a passport number? ›

The passport number in the new passport book begins with a letter, followed by eight numbers. The number is located in the top right corner of your data page and the bottom of each page in the book.

What app can verify passport? ›

The ReadID Me app (previously known as NFC Passport Reader) reads and verifies the NFC chip embedded in your electronic passport and other ICAO compliant identity documents (ePassports, or in ICAO Doc 9303 terminology, electronic Machine Readable Travel Documents, eMRTD).

What does it mean to validate a passport? ›

Biometric suite for customer's identity…

Passport verification refers to the process of confirming the authenticity and validity of a passport. This process involves a thorough verification of the details present in the passport.

What does it mean when a passport is validated? ›

Passport validity is the length of time a passport can be used to travel to another country, or be used as a valid form of identification within or outside the issuing country before its date of expiration.

Is passport number 9 or 10 digits? ›

Passport Card Number VS Passport Number

Your passport book and passport card have two different numbers. Passport card numbers start with the letter C followed by eight numbers, while your passport book has nine digits that are unique to each US citizen.

How to validate passport number in JavaScript? ›

Users can follow the syntax below to use the regular expression to validate the passport number in ReactJS. const regex = /^[A-PR-WY][1-9]\d\s?\ d{4}[1-9]$/; let isValid = regex. test(passport);

What is the 9 digit passport number? ›

Digitally embedded into the electronic chip. 9 digits, printed on page 1. These are entered on the biodata page (page 2) in the same style as the personal details. The serial number is perforated from page 1 of the passport through to the rear cover.

Are all passport numbers alphanumeric? ›

U.S. Passport numbers must be between six and nine alphanumeric characters (letters and numbers).

How many characters do passport numbers have? ›

US Passports contain a variety of identification features, including passport numbers, which are between six and nine characters, including letters and numbers.

Which country's passport number starts with n? ›

Country code ('LKA' for Sri Lanka) Passport No. (Starting with 'N' for Ordinary Passport, 'OL' for Official Passport and 'D' for Diplomatic Passport)

How to track a passport with a tracking number? ›

Check the Speed Post Status Using the Passport Seva Kendra (PSK) Website
  1. Visit the Track Application Status link of PSK.
  2. Then, enter the valid input in the Select Application Type.
  3. After that, enter a 15-digit file number. ...
  4. Next, enter your Date of Birth.
  5. Finally, click 'Track Status'.
Jan 2, 2024

Does passport number change in India? ›

There is no passport number change after renewal. Only the validity date is changed. Since passport number renewal does not take place, the existing passport is given to the passport holder. In case of passport re-issuance, a new passport with a passport number renewal is given to the passport holder.

Top Articles
Latest Posts
Article information

Author: Aron Pacocha

Last Updated:

Views: 6262

Rating: 4.8 / 5 (68 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Aron Pacocha

Birthday: 1999-08-12

Address: 3808 Moen Corner, Gorczanyport, FL 67364-2074

Phone: +393457723392

Job: Retail Consultant

Hobby: Jewelry making, Cooking, Gaming, Reading, Juggling, Cabaret, Origami

Introduction: My name is Aron Pacocha, I am a happy, tasty, innocent, proud, talented, courageous, magnificent person who loves writing and wants to share my knowledge and understanding with you.