convert(Regex, ::DateFormat)?

I’m processing some ugly log-files that contain different timestamp formats.

So I want to both search for an timestamp embedded in the line with a Regex, and then parse the timestamp if I find it.

To keep things DRY, it would be nice if the DateFormat knew how to become a Regex.

Being a newbie, perhaps I’m missing it.

BTW, as an old fart who’s played around with just about every language invented (Algol60 anyone?), Julia is the first new language to get me exited in a while. [I actually looked at it several years ago, but was unimpressed. Either I didn’t “get” it, or Julia has come a long way]

I don’t think that’s easily possible. The date parsing code does not work with regexes, so I think the way to check that a string is a date of certain format is to try and parse it with that format. However, that doesn’t help you for finding candidate date strings inside your log strings. What kinds of date formats are you expecting in your logs? Maybe it’s easier to write one or two catch-all regexes and then tryparse with the different date formats you expect on each match.

2 Likes