Lol, wow guys
Edit:
I like Bingo and Bongo!
If var is a date, how? Topic is solved
-
- Posts: 27
- Joined: 06 Mar 2022, 17:45
Re: If var is a date, how?
Another way.
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
}
Re: If var is a date, how?
Emile HasKey's version varied:
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
}
Re: If var is a date, how?
So many good AHK-ers here
RegEx is magic. Where to learn all these creepy things that do things I can not understand?
RegEx is magic. Where to learn all these creepy things that do things I can not understand?
Re: If var is a date, how?
@Krd —
https://regexone.com/ is a good place to learn RegEx in a step-by-step tutorial fashion.
https://regex101.com/ is a good place for building and testing your RegEx patterns and is a good reference in general.
https://regexone.com/ is a good place to learn RegEx in a step-by-step tutorial fashion.
https://regex101.com/ is a good place for building and testing your RegEx patterns and is a good reference in general.
Re: If var is a date, how?
I would never be able to find them my self. So RegEx is not AHK-special thing? At least the one used in AHK? I have started with https://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm and I miss some more examples. Coding language is not so easy for a long timer noob
I liked the first link very much. Thank you boiler!
I liked the first link very much. Thank you boiler!
Re: If var is a date, how?
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.