I am writing a node.JS application to parse google takeout data from google photos, for EXIF data.
I am not good at regex, and have tried sites such as regexr.com to no avail, since there are a lot of unknowns. But I am wondering if there is a more efficient way of doing this?
Say I could have various potential strings
"IMG_20150628_184721-ANIMATION" # There is a date + time within, but they are not in an ISO format, also non-regular characters
"Screenshot_2015-06-27-22-51-00" # Has a date/time at the end, but also has useless string within it
"2015-06-28" # Cleanly formatted date without time
"2015-06-28 22:51:05" # Cleanly formatted date and time
"2015-06-28 #1" # Date + Space and Extra characters that I don't want
"2015-06-28 #3 " # Date + Space and extra characters that I don't want and a trailing space
"2015-06-18-19" # Date + An extra number (happens to be the next day)
"NoDateOrTimeInThisString" # No Date
"IMG_1234" # No date
This list is non exhaustive, and there may be other strings before+after dates. It is also possible that a date/time will not actually be in the string
I don't have any way of knowing which of these particular file names I am going to end up with, and within my knowledge scope I don't know how I would be able to extract the dates from each of these.
Does anyone have any idea how i'd go about doing this in JavaScript?Such as a library? If possible i'd like to be able to get it into a JS Date/Time object. But I have no idea how i'd go about this.