Re: If var is a date, how?
Posted: 30 Jun 2022, 07:20
Lol, wow guys
Edit:
I like Bingo and Bongo!
Edit:
I like Bingo and Bongo!
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=105602
Code: Select all
; check date is valid:
date1 := "13.12.2020"
date2 := "33.12.2020"
MsgBox % Is_dd_MM_yyyy(date1) ; True
MsgBox % Is_dd_MM_yyyy(date2) ; False
return
Is_dd_MM_yyyy(date)
{
local date2
if !RegExMatch(date, "^\d{2}\.\d{2}\.\d{4}$")
return False
date2 := Format("{3:04}{2:02}{1:02}", StrSplit(date, ".")*)
if date2 is Time
return True
return False
}
Code: Select all
; check date is valid:
date1 := "13.12.2020"
date2 := "33.12.2020"
MsgBox % Is_dd_MM_yyyy(date1) ; True
MsgBox % Is_dd_MM_yyyy(date2) ; False
return
Is_dd_MM_yyyy(date)
{
; local D ; this does not work!
if !RegExMatch(date, "^(\d{2})\.(\d{2})\.(\d{4})$", D)
return False
D := D3 D2 D1
if D is Time
return True
return False
}
Both of those sites and many others are easily found with a simple google search.
No, regular expressions predate AHK by lot.
No, AHK uses Perl Compatible Regular Expression (PCRE), which is a library used by many programming languages.