Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

Persian Checklist #2

Closed
HamedFathi opened this issue Apr 20, 2020 · 1 comment
Closed

Persian Checklist #2

HamedFathi opened this issue Apr 20, 2020 · 1 comment

Comments

@HamedFathi
Copy link
Member

HamedFathi commented Apr 20, 2020

PersianUtils by Typescript

[ ] Persian.js
[ ] Rial.js
[ ] Check Iranian National Code Validity
[ ] Iranian postal code validation
[ ] NumToPersian

Iranian postal code validation

this is some rules about this regex:
It's all numeric
10 digit count
don't use 0 in first 5 digit
don't use 2 in postal code
First 4 digit is not the same
The 5th digit cannot be 5
all digits aren't the same

The following regex satisifes your conditions:
\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b

Explanation:
\b - a word boundary
(?!(\d)\1{3}) - negative lookahead to make sure that the first 4 digits are not the same.
[13-9]{4} - matches 4 occurrences of all the digits except 0 and 2
[1346-9] - matches a single digit that is not a 0,2 or 5
[013-9]{5} - matches 5 occurrences of all the digits except 2
\b - a word boundary

I made PersianToolkit for this purpose.

@HamedFathi
Copy link
Member Author

closed in favor of #4

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant