I have a regex for validating persian date like this:
((((u0661u0663|u0661u0664)[u0660-u0669]{2})(/|-)(u0660[u0660-u0669]{1}|u0661u0661|u0661u0662))(/|-)(u0660[u0661-u0669]{1}|(u0661|u0662)[u0660-u0669]{1}|u0663u0660|u0663u0661)) 1. (u0661u0663|u0661u0664)[u0660-u0669]{2} : only match ۱۳|۱۴ followed by two char between [٠-۹] match: ۱۳۹۹ , ۱۴٠٠ not match: ۱۲۹۹ 2. separator can be / | - 3. (u0660[u0660-u0669]{1}|u0661u0661|u0661u0662)) : (٠ with following single char between [۱-۹]) | ۱۱ | ۱۲ match: ٠۱ , ٠۹, ۱۱ , ۱۲ not match: ۱۳ , ۲۱ , ٠٠ , etc 4. (u0660[u0661-u0669]{1}|(u0661|u0662)[u0660-u0669]{1}|u0663u0660|u0663u0661) : match (٠۱-٠۹) | (۱۱ - ۲۹) | ۳٠ | ۳۱
but testing in this test link does not pass. am I doing any thing wrong?
Advertisement
Answer
thanks to @JvdV, I made a mistake in getting unicode of the persian number characters. the right regex would be:
((((u06F1u06F3|u06F1u06F4)[u06F0-u06F9]{2})(/|-)(u06F0[u06F0-u06F9]{1}|u06F1u06F1|u06F1u06F2))(/|-)(u06F0[u06F1-u06F9]{1}|(u06F1|u06F2)[u06F0-u06F9]{1}|u06F3u06F0|u06F3u06F1))