india-pincode-regex/pincode-regex.js

29 lines
34 KiB
JavaScript
Raw Permalink Normal View History

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Pincode = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
},{}],2:[function(require,module,exports){
const readline = require("readline");
2023-07-10 16:18:45 +00:00
let contents = "(1(?:9(?:310[1389]|001[0-2457-9]|440[124])|8(?:41(?:4[1-58]|0[124])|513[1-35]|2(?:31[1-35]|12[124-8])|114[135]|001[0-35-9])|(?:941|800)0[1-79]|7(?:7(?:21[0-39]|1(?:1[0-47-9]|0[13-9])|0(?:4[0-58]|3[13489]|0[15-7]))|6(?:32[013-6]|1(?:2[58]|1[015]|0[1-37-9])|0(?:7[135-7]|4[0-57-9]|3[0-36-9]|2[1-35-9]))|621[013-9]|5(?:1(?:3[0-4689]|2[13-689])|0(?:4[025-9]|2[013-9]))|4(?:50[357]|31[0-24-79]|0(?:2[1346-9]|1[1-357]))|3(?:2(?:3[03-6]|2[0-359]|1[0-578])|02[1-79])|1(?:10[23]|01[0-589]))|9212[1-69]|600(?:5[59]|4[37]|3[06]|2[0235]|0[1-69])|5(?:21(?:2[1-48]|1[2-8]|0[17])|110[1-68])|9002[013-5]|(?:7320|6001)[124-9]|(?:7203|5121)[0-4]|7630[1-689]|(?:8515|7510)[1-6]|(?:923|842|510)0[1-6]|7606[0-7]|4(?:803[013-5]|502[2-79]|4(?:62[0-689]|30[1-356]|2(?:1[0-46]|0[124-9]))|404[0-4]|441[015-9]|4819|3(?:5(?:3[0-4]|2[015-9]|0[124-7])|4(?:1[0-69]|0[126-9])|1(?:49|0[1-357-9])|00[1-689])|205[02-8]|480[1-6]|(?:41|36)0[1-6]|1(?:20[1-6]|1(?:2[0-35-7]|1[02-9])|0(?:1[0-7]|0[1-46-8]))|0(?:50[167]|4(?:1[237]|0[125-8])|30[16-8]|1(?:2[3-8]|0[1-389])))|4801[7-9]|(?:9322|7400|5200|4710)[1-5]|(?:935|43[23])0[1-5]|8[12]20[1-7]|(?:9340|8112|4(?:60|42)2)[1-4]|(?:601|406)0[1-4]|(?:8214|4700)[1-8]|3(?:6(?:1(?:56|3[0-24-6]|2[89]|1[7-9])|0(?:3[03-58]|2[0167]))|4(?:20[1-5]|1(?:1[2-46-8]|0[1-57-9])|00[3578])|500[1-4]|3(?:20[1-7]|10[1-4]|00[14-68])|604[2-4]|2(?:1(?:57|4[05]|1[3-7]|0[1-8])|0(?:54|4[016]|3[679]|2[2-4]))|1(?:40[2389]|30[124-6]|0(?:3[09]|2[1-47-9])))|(?:9221|7(?:505|303)|4401)[0-2]|(?:8(?:210|122)|7310)[14]|(?:8115|6006|5213|4(?:3[04]2|080)|3212)2|7(?:622|507|440)5|(?:7(?:403|122)|4611)[0-6]|(?:841|743)2[01]|(?:7514|44[56]3)[0-3]|5202[0-68]|(?:40|35)133|(?:9(?:312|223|11[01])|8(?:520|113)|5203|4200)[1-3]|(?:9[34]3|7(?:64|41)|4(?:72|47)|311)0[1-3]|(?:446|351)0[1-36]|(?:9(?:3(?:41|20)|2(?:22|10)|112)|8(?:512|2(?:30|16)|111)|7300|6007|5111|4(?:7(?:11|02)|600|500|431|201|140)|3(?:502|200|100)|(?:924|7(?:7[3-6]|66|42|22|13)|514|4(?:73|51|18|0[029]))0)1|8523[34]|(?:9(?:220|113)|8(?:5(?:21|10)|415|222|110)|7[26]00|4(?:800|442|142)|(?:9[14]2|765|513|407|333)0)[12]|2(?:7(?:3(?:1[0-2]|0[6-9])|11[14]|0(?:4[0-356]|3[0-25]|2[125-9]))|61(?:52|25|1[0-6])|5(?:1(?:2[01]|1[0-3]|0[1-46])|0(?:7[5-8]|5[0-68]|4[247-9]|3[37-9]|0[14-7]))|5133|4(?:50[14-8]|40[146]|303|1(?:4[126]|0[2-9]))|411[1-3]|(?:501|400|[57]20)1|3(?:30[1-3]|10[1-36]|[45]01|0(?:3[145]|2[1347-9]|01))|451[34]|(?:610|4(?:41|20|02)|341)[12]|2(?:50[2-68]|41[34]|10[1-578]|0(?:98|5[12]|1[0-25-8]))|1(?:10[1-35-7]|01[02-5]))|(?:(?:8(?:23|00)|772)2|5151|4206|3301|2(?:506|401|311))0|4403[0-79]|7(?:609|211)[0-8]|(?:7(?:702|6(?:31|20)|50[13]|121)|4(?:8(?:10|02)|4(?:5[12]|02)|20[34]|011))[0-9]|(?:9000|7(?:720|60[58]|500|430|2(?:10|02)|1[02]0)|51[25]0|4(?:(?:61|4[045])0|3[15]1|202|1(?:41|10))|2[12]00)[1-9]|10(?:110|0(?:9[0-79]|7[0-8]|[1-468][0-9]|[05][1-9])))|2(?:8(?:413[56]|313[056]|1[04]0[13-6]|311[0-59])|7(?:7(?:50[1-46]|2(?:1[013469]|0[1-57-9]))|4(?:80[126-8]|50[125689])|3(?:20[1-379]|15[12578])|6288|21(?:9[0-59]|8[129]|48|2[3-9])|1(?:8(?:7[0-25]|2[145])|60[1-479]|50[2-4]|31[0-39]))|6(?:3(?:6(?:7[689]|6[013-57]|5[1-35689])|1(?:5[0-36-9]|4[02589]|3[24-9]|2[6-8]))|2(?:57[26]|30[2589])|240[1256]|150[1256])|5(?:13(?:2[07]|1[014-689])|0(?:6(?:1[1579]|0[169])|10[1346]))|7112[2-69]|6362[0-689]|6113[156]|7510[1-35]|7301[02-7]|74182|4(?:91(?:9[2-69]|8[0156]|3[0-25-7])|81(?:7[19]|4[02356])|7(?:656|12[0-29])|6(?:74[5-79]|4(?:8[1-36-8]|5[35]|4[0-689]|2[124-9])|1(?:9[34]|5[059]|4[1246-9]|2[13-57-9]))|520[15-8]|755[14]|530[14]|914[156]|4(?:71[235-7]|50[14]|2(?:3[156]|2[1-35])|10[2-5])|3(?:72[02-7]|40[1-37]|12[236])|2(?:40[15-7]|30[135-7]|22[0136]|042))|6253[0-4]|(?:504|493)0[1246]|8150[124]|3(?:323[0-4]|2(?:33[0-369]|11[018])|121[0-35-9]|0(?:30[1246]|20[124]|12[14-9]))|(?:8522|4611)3|4643[159]|718[34][015]|4815[89]|(?:7613|5130)[15-9]|7640[2-6]|3122[0-6]|81104|(?:(?:832|753)0|4(?:673|140))[1-7]|4112[1-7]|(?:6212|4676|3(?:131|014))[1-4]|(?:7(?:73|46|19)|4(?:43|12))0[1-4]|4800[1-35-9]|(?:4(?:819|627)|3(?:232|120))[5-9]|2(?:9(?:40[124-68]|31[016]|21[0-256]|103)|81(?:5[159]|2[015]|1[89])|780[15-9]|5(?:4(?:1[2-6]|0[13-59])|
const regex = new RegExp(contents, "gm");
const exactRegex = new RegExp("^" + contents + "$");
module.exports = {
2023-07-10 16:18:45 +00:00
// Validates an exact 6 digit string as a valid pincode
validate: function(pin) {
2023-07-10 16:18:45 +00:00
if (exactRegex.test(pin)) {
return true;
}
return false;
2023-07-10 16:18:45 +00:00
},
// Returns all valid PIN codes for a given address
search: function(address) {
return Array.from(address.matchAll(regex), (x) => x[0])
},
regex: regex,
exactRegex: exactRegex
};
},{"readline":1}]},{},[2])(2)
});