I'm working in Sublime Text 3 with a large text file that has entries separated by lines. I'm looking for a regular expression that will:
DD-MM-YYYY
formatDD/MM/YYYY
format If both would be too complicated, then just the first example will do.
I haven't done anything to work towards such a regex, because it's honestly way above my knowledge of it and I wouldn't know where to start, and looking at similar answers dealing with regex validation of date formats confirms those suspicions for me.
Thanks in advance for any help.
This pattern will work for your conditon. Strictly not allowed month to date and vice versa.
^([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0]?[1-9]|[1][0-2])[./-]([0-9]{4}|[0-9]{2})$
This pattern will match these formats: (Date, Month, Year)
25.04.2017
02.04.2017
2.4.2017
25/04/2017
5/12/2017
15/2/2017
25-04-2017
6-10-2017
16-5-2017
This regex matches your example:
[0-9]{2}[-|\/]{1}[0-9]{2}[-|\/]{1}[0-9]{4}
but if you write wrong date (like 31 Feb) this regex match it.
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