BugFix

Untitled

Sep 23rd, 2020
966
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $text1 = "Thursday, December 19, 2019 10:10 AM 668 about_this_site.txt"
  2. $text2 = "December 19, 2019 10:10 AM 668 about_this_site.txt"
  3. $text3 = "19 December 2019 10:10 AM 668 about_this_site.txt"
  4. $text4 = "2019-09-19 10:10 AM 668 about_this_site.txt"
  5. $text5 = "2019/09/19 10:10 AM 668 about_this_site.txt"
  6.  
  7. ConsoleWrite(_HasUSDate($text1) & @CRLF)
  8. ConsoleWrite(_HasUSDate($text2) & @CRLF)
  9. ConsoleWrite(_HasUSDate($text3) & @CRLF)
  10. ConsoleWrite(_HasUSDate($text4) & @CRLF)
  11. ConsoleWrite(_HasUSDate($text5) & @CRLF)
  12.  
  13. Func _HasUSDate($s)
  14.     Local Static $aUSDate[][2] = [ _
  15.     ["full_1","^\w+, \w+ \d{2}, \d{4}"], _ ; Tuesday, September 22, 2020
  16.     ["full_2","^\w+, \d{2} \w+ \d{4}"], _  ; Tuesday, 22 September 2020
  17.     ["long_1","^\w+ \d{2}, \d{4}"], _      ; September 22, 2020
  18.     ["long_2","^\d{2} \w+ \d{4}"], _       ; 22 September 2020
  19.     ["short_1","^\d{4}/\d{2}/\d{2}"], _    ; 2020/09/22
  20.     ["short_2","^\d{2}/\d{2}/\d{4}"], _    ; 09/22/2020
  21.     ["short_3","^\d{4}-\d{2}-\d{2}"]]      ; 2020-09-22
  22.     For $i = 0 To UBound($aUSDate) -1
  23.         If StringRegExp($s, $aUSDate[$i][1]) Then Return $aUSDate[$i][0]
  24.     Next
  25.     Return ""
  26. EndFunc
RAW Paste Data