Recognise an arbitrary date string

后端 未结 14 861
抹茶落季
抹茶落季 2020-12-01 16:18

I need to be able to recognise date strings. It doesn\'t matter if I can not distinguish between month and date (e.g. 12/12/10), I just need to classify the string as being

14条回答
  •  一生所求
    2020-12-01 16:44

    It is virtually impossible to recognize all possible date formats as dates using "standard" algorithms. That's just because there are so many of them.

    We, humans are capable of doing that just because we learned that something like 2010-03-31 resembles date. In other words, I would suggest to use Machine Learning algorithms and teach your program to recognize valid date sequences. With Google Prediction API that should be feasible.

    Or you can use Regular Expressions as suggested above, to detect some but not all date formats.

提交回复
热议问题