I want a Regular Expression for validation Persian date like 1396/4/3
, 1396/12/08
or something else.
in other words, I want to ensure that format of Persian Date (as String
) is some thing like these valid formats are:
1.YYYY/MM/DD
2.YYYY/MM/D
3.YYYY/M/DD
4.YYYY/M/D
any Solution?
use this Regex :
/^[1-4]\d{3}\/((0[1-6]\/((3[0-1])|([1-2][0-9])|(0[1-9])))|((1[0-2]|(0[7-9]))\/(30|([1-2][0-9])|(0[1-9]))))$/
this regex in jquery full check your persian date template
Year : 4 digits starts with 1300 or 1400
Month,Day : for the 6 first months of a year calculate 31 days and for the 5 next months of a year calculate 30 days and for last month of a year calculate 29 days
This is a bit long but it works everywhere (for example in grep -E
in bash):
^[1][1-4][0-9]{2}\/((0[1-6]\/(0[1-9]|[1-2][0-9]|3[0-1]))|(0[7-9]\/(0[1-9]|[1-2][0-9]|30))|(1[0-1]\/(0[1-9]|[1-2][0-9]|30))|(12\/(0[1-9]|[1-2][0-9])))
the format is: YYYY/MM/DD
from year 1100 to 1499
and Esfand is 29 days in this expression.
use this regex:
^(\\d{4})/(0?[1-9]|1[012])/(0?[1-9]|[12][0-9]|3[01])$
with this regex:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With