/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String c1
= "S"; // First letter in surname coming from the EditText (with P before) String c2
= "F"; // First letter in name coming from another EditText (not with P before) String pan
= "AWSPS1234Z"; // true System.
out.
println(pan.
matches("[A-Z]{3}([CHFATBLJGP])(?:(?<=P)" + c1
+ "|(?<!P)" + c2
+ ")[0-9]{4}[A-Z]")); pan = "AWSCF1234Z"; // true
System.
out.
println(pan.
matches("[A-Z]{3}([CHFATBLJGP])(?:(?<=P)" + c1
+ "|(?<!P)" + c2
+ ")[0-9]{4}[A-Z]")); pan = "AWSCS1234Z"; // false
System.
out.
println(pan.
matches("[A-Z]{3}([CHFATBLJGP])(?:(?<=P)" + c1
+ "|(?<!P)" + c2
+ ")[0-9]{4}[A-Z]"));
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVN0cmluZyBjMSA9ICJTIjsgLy8gRmlyc3QgbGV0dGVyIGluIHN1cm5hbWUgY29taW5nIGZyb20gdGhlIEVkaXRUZXh0ICh3aXRoIFAgYmVmb3JlKQoJCVN0cmluZyBjMiA9ICJGIjsgLy8gRmlyc3QgbGV0dGVyIGluIG5hbWUgY29taW5nIGZyb20gYW5vdGhlciBFZGl0VGV4dCAobm90IHdpdGggUCBiZWZvcmUpCgkJU3RyaW5nIHB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