Regex query - 25/07/06 02:16 AM
In a dialog I have two edit boxes, one containing the format for the date display, the other for the time display.
The default settings are ddd mmm dd yyyy & hh:nn:ss tt
I was looking for a way to prevent someone from changing these to an improper date/time display format.
Example for the date: dnd mhm dd yssy
I asked around and did some reading, coming up with the following for a regex, but I guess my knowledge is still lacking at some point, as it doesn't work completely.
If someone could fix this up and explain what and why they did, I (hopefully) will be able to modify the code so that it works similarily for the box with the time format.
Here's what I was able to come up with.
Dialog ID 103 contains the date format, and 105 the time format.
The default settings are ddd mmm dd yyyy & hh:nn:ss tt
I was looking for a way to prevent someone from changing these to an improper date/time display format.
Example for the date: dnd mhm dd yssy
I asked around and did some reading, coming up with the following for a regex, but I guess my knowledge is still lacking at some point, as it doesn't work completely.
If someone could fix this up and explain what and why they did, I (hopefully) will be able to modify the code so that it works similarily for the box with the time format.
Here's what I was able to come up with.
Code:
on *:dialog:channel_control:edit:103,105:{ var %date.fmt = $did(Channel_Control,103) var %time.fmt = $did(Channel_Control,105) if !$regex(%date.fmt,[^dmy.-\s]) { if $regex(%date.fmt,|d|dd|ddd|dddd) && !$regex(%date.fmt,\bddddd\b) { if $regex(%date.fmt,|m|mm|mmm|mmmm) && !$regex(%date.fmt,\bmmmmm\b) { if $regex(%date.fmt,|y|yy|yyy|yyyy) && !$regex(%date.fmt,\byyyyy\b) { } else { echo -a error in year did -ra $dname $did $iif($did == 105,hh:nn:ss tt,ddd mmm dd yyyy) } } else { echo -a error in month did -ra $dname $did $iif($did == 105,hh:nn:ss tt,ddd mmm dd yyyy) } } else { echo -a error in day did -ra $dname $did $iif($did == 105,hh:nn:ss tt,ddd mmm dd yyyy) } } .timertime -m 0 500 title }
Dialog ID 103 contains the date format, and 105 the time format.