#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mix)#Modifiers << NOT GOING TO DO THESE HERE." & @CRLF & _
" #∂ Before After Until in?Between" & @CRLF & _
" #∂ onwards" & @CRLF & _
"#Time-Time << Don't need as both times will match" & @CRLF & _
"#Lonely HOURS List: 10,time or 12 <not going to do this" & @CRLF & _
"" & @CRLF & _
"# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " & @CRLF & _
"# - - - - - - - - - - - BIG TIME REGEX - - - - - - - - - - - - " & @CRLF & _
"" & @CRLF & _
"#LONELY HOURS" & @CRLF & _
"#These guys are just \d\d. So we identify them through proximity to known times" & @CRLF & _
"(?:" & @CRLF & _
" #Boundary Lookaround" & @CRLF & _
" (?<=[ ]|^|[^\d\.:\r\n$£-])" & @CRLF & _
" #hour - you always have hours" & @CRLF & _
" (?:1[0-9]|2[0-4]|0?[0-9])" & @CRLF & _
" " & @CRLF & _
" (?:" & @CRLF & _
" #Hour [or / to - , and]" & @CRLF & _
" #People don't say "12pm or 3?" much. Build it if it comes up." & @CRLF & _
" (?:[ ]? (?:or|[,/-]|to|and) [ ]?)" & @CRLF & _
" )" & @CRLF & _
"){0,3}" & @CRLF & _
"" & @CRLF & _
"#TIME BASICS:" & @CRLF & _
"#Basic times that are definitely times. Have to come last so longer strings match first." & @CRLF & _
" #Boundary Lookaround (BREAK THIS FOR THE LONELY NUMBERS)" & @CRLF & _
"# (?<=[ ]|^|[^\d\.:\r\n$£-])" & @CRLF & _
" #hour - you always have hours" & @CRLF & _
" ( (?:1[0-9]|2[0-4]|0?[0-9]) )" & @CRLF & _
" #Clarifier. Minutes, AM|PM, a TimeZone or a combination." & @CRLF & _
" (" & @CRLF & _
" #Minutes" & @CRLF & _
" (?:[ ]?[\:\. ][ ]?) ([0-5][0-9])" & @CRLF & _
" #AM|PM" & @CRLF & _
" | (?:[ ]?[ap]m|[ ]?o\'?[ ]?clock)" & @CRLF & _
" #TimeZones" & @CRLF & _
" | (?:[ ]? (?:PS?T|GMT|∆USA|∆US|ET|BST|∆UK" & @CRLF & _
" |UK[ ]?[Tt]ime|[Ee]astern[ ]?[Tt]ime|[Pp]acific[ ]?[Tt]ime|[Cc]entral[ ]?[Tt]ime" & @CRLF & _
" |∆UTC|ACDT|ACST|ACT|ACT|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|AMT|ART|AST|AST|AWDT" & @CRLF & _
" |AWST|AZOST|AZT|BDT|BDT|BIOT|BRST|BRT|BST|BST|BST|BTT|CCT|CDT|CDT|CEDT|CEST|CET" & @CRLF & _
" |CHADT|CHAST|CHOT|ChST|CHUT|CIST|CIT|CKT|CLST|CLT|COT|CST|CST|CST|CST|CST|CT|CVT" & @CRLF & _
" |CWST|CXT|DAVT|DDUT|DFT|EASST|ECT|ECT|EDT|EEDT|EEST|EET|EGST|EGT|EIT|EST|EST|FET" & @CRLF & _
" |FJT|FKST|FKST|FKT|FNT|GALT|GAMT|GFT|GILT|GIT|GMT|GST|GST|GYT|HADT|HAEC|HAST|HKT" & @CRLF & _
" |HMT|HOVT|HST|IBST|ICT|IDT|IRDT|IRKT|IRST|IST|IST|IST|JST|KGT|KOST|KRAT|KST|LHST" & @CRLF & _
" |LHST|LINT|MAGT|MART|MAWT|MDT|MET|MEST|MHT|MIST|MMT|MSK|MST|MST|MST|MUT|MVT|MYT|NCT" & @CRLF & _
" |NDT|NFT|NPT|NST|NT|NUT|NZDT|NZST|OMST|ORAT|PDT|PETT|PGT|PHOT|PKT|PMDT|PMST|PONT" & @CRLF & _
" |PST|PST|PYST|PYT|RET|ROTT|SAKT|SAMT|SAST|SBT|SCT|SGT|SLST|SRET|SRT|SST|SST|SYOT" & @CRLF & _
" |TAHT|THA|TFT|TJT|TKT|TLT|TMT|TOT|TVT|ULAT|USZ1|UYST|UYT|UZT|VET|VLAT|VOLT|VOST" & @CRLF & _
" |VUT|WAKT|WAST|WAT|WEDT|WEST|WET|WST|YAKT)\b )" & @CRLF & _
" #Now enable the combo. Note ideally we would say "use one of each" e.g., =/10:234210" & @CRLF & _
" ){1,3}" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"#Lonely HOURS: List of Military times <Here we have enough info to allow no ":"." & @CRLF & _
" |( (?:" & @CRLF & _
" #Boundary Lookaround" & @CRLF & _
" (?<=[ ]|^|[^\d\.:\r\n$£-])" & @CRLF & _
" #Must open with a military time, no "445" must be "0445"" & @CRLF & _
" (?:1[0-9]|2[0-4]|0[0-9])" & @CRLF & _
" (?:[ ]?[0-5][0-9][ ]?)" & @CRLF & _
" #or and" & @CRLF & _
" (?:[ ]? (?:or|[,/-]|to|and) [ ]?)" & @CRLF & _
" #2-4 military times, including the closing one" & @CRLF & _
" ){1,3}" & @CRLF & _
" #Must also end with a military time" & @CRLF & _
" (?:1[0-9]|2[0-4]|0[0-9])" & @CRLF & _
" (?:[ ]?[0-5][0-9][ ]?)" & @CRLF & _
" )" & @CRLF & _
"" & @CRLF & _
"#Post rationalise the boundary criteria (?:\b|$|,\b)"
Local $sString = "NEW TIME MATCHING REGEX" & @CRLF & _
"*** REGEX 1: LONELY NUMBERS ***" & @CRLF & _
"12 or 3pm" & @CRLF & _
"4/5CET" & @CRLF & _
"5-6pm" & @CRLF & _
"2,4,5pm" & @CRLF & _
"1,3 or 6pm" & @CRLF & _
"OK. 1,2,3 and 5pm are available" & @CRLF & _
"12pm or 3pm <Shouldn't match "or"" & @CRLF & _
"" & @CRLF & _
"#Military times" & @CRLF & _
"1200 or 1300." & @CRLF & _
"1100,1300 or 1400." & @CRLF & _
"121212121212121212 <don't match" & @CRLF & _
"" & @CRLF & _
"*** REGEX 2: BASICS ***" & @CRLF & _
"1" & @CRLF & _
"11am or 2pm" & @CRLF & _
"12pm" & @CRLF & _
"12 CET" & @CRLF & _
"12pm CET" & @CRLF & _
"12.32pm" & @CRLF & _
"14 pm" & @CRLF & _
"10.00?" & @CRLF & _
"0.15" & @CRLF & _
"3 : 34" & @CRLF & _
"10 53" & @CRLF & _
"00.15" & @CRLF & _
"at3.00?" & @CRLF & _
"10amis good for me" & @CRLF & _
" 4 oclock" & @CRLF & _
"2o'clock" & @CRLF & _
"2 o clock" & @CRLF & _
"yes,3 am" & @CRLF & _
"12.50 GBP" & @CRLF & _
"USD 4.00" & @CRLF & _
"" & @CRLF & _
"£12.50" & @CRLF & _
"10.93?" & @CRLF & _
"00000" & @CRLF & _
"0000-559" & @CRLF & _
"00001" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"00001" & @CRLF & _
"00001" & @CRLF & _
"01300" & @CRLF & _
"01700" & @CRLF & _
"from 2 - 6" & @CRLF & _
"there is about 3 of them" & @CRLF & _
"Not sure, maybe 14 apples?" & @CRLF & _
"how about 10 tomorrow? << should fail" & @CRLF & _
"10 tomorrow?" & @CRLF & _
"about £23.00" & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"10,11 or 12" & @CRLF & _
"10, 11 or 2?" & @CRLF & _
"10 or 12?" & @CRLF & _
"10 or my place?" & @CRLF & _
"1030 or 1130" & @CRLF & _
"10.30 or 12?" & @CRLF & _
"10 and 11 work" & @CRLF & _
"10, 11, 12th?" & @CRLF & _
"" & @CRLF & _
"1,000" & @CRLF & _
""
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; Present the entire match result
_ArrayDisplay($aArray, "Result")
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm