-2

I have a regex for validating persian date like this:

((((\u0661\u0663|\u0661\u0664)[\u0660-\u0669]{2})(\/|-)(\u0660[\u0660-\u0669]{1}|\u0661\u0661|\u0661\u0662))(\/|-)(\u0660[\u0661-\u0669]{1}|(\u0661|\u0662)[\u0660-\u0669]{1}|\u0663\u0660|\u0663\u0661))

1.
(\u0661\u0663|\u0661\u0664)[\u0660-\u0669]{2} : only match ۱۳|۱۴ followed by two char between [٠-۹] 
match: ۱۳۹۹ , ۱۴٠٠
not match: ۱۲۹۹
2. 
separator can be / | -
3.
(\u0660[\u0660-\u0669]{1}|\u0661\u0661|\u0661\u0662)) : (٠ with following single char between [۱-۹]) | ۱۱ | ۱۲
match: ٠۱ , ٠۹, ۱۱ , ۱۲
not match: ۱۳ , ۲۱ , ٠٠ , etc
4.
(\u0660[\u0661-\u0669]{1}|(\u0661|\u0662)[\u0660-\u0669]{1}|\u0663\u0660|\u0663\u0661) : match (٠۱-٠۹) |  (۱۱ - ۲۹) | ۳٠ | ۳۱

but testing in this test link does not pass. am I doing any thing wrong?

Arsalan
  • 709
  • 2
  • 14
  • 27
  • Maybe you are confused with the ["EXTENDED ARABIC-INDIC DIGIT"](https://stackoverflow.com/q/1676460/9758194) as seen at the linked post. See what happens if I change the unicode blocks [here](https://regexr.com/5j129) – JvdV Dec 22 '20 at 09:21
  • @JvdV No, I used persian characters in my test and the regex – Arsalan Dec 22 '20 at 09:23
  • But, the text you tested it on clearly is triggered by the extended digits as seen in the link I showed. – JvdV Dec 22 '20 at 09:24
  • @JvdV yes they are to close in look, but I know the difference – Arsalan Dec 22 '20 at 09:30
  • 1
    Then I'm confused. The sample text in your link **is** triggered when you change all your code blocks to "U+06Fn" notation. So you have *not* used the right unicode blocks currently. What is confusing about that? Or....what am I missing here? – JvdV Dec 22 '20 at 09:32
  • @JvdV, yes you are right, my bad – Arsalan Dec 22 '20 at 09:38

1 Answers1

-1

thanks to @JvdV, I made a mistake in getting unicode of the persian number characters. the right regex would be:

((((\u06F1\u06F3|\u06F1\u06F4)[\u06F0-\u06F9]{2})(\/|-)(\u06F0[\u06F0-\u06F9]{1}|\u06F1\u06F1|\u06F1\u06F2))(\/|-)(\u06F0[\u06F1-\u06F9]{1}|(\u06F1|\u06F2)[\u06F0-\u06F9]{1}|\u06F3\u06F0|\u06F3\u06F1))
Arsalan
  • 709
  • 2
  • 14
  • 27