Extracting year from string in python

后端 未结 3 1375
一整个雨季
一整个雨季 2021-01-07 02:43

How can I parse the foll. in python to extract the year:

\'years since 1250-01-01 0:0:0\'

The answer should be 1250

3条回答
  •  长发绾君心
    2021-01-07 03:14

    The following regex should make the four digit year available as the first capture group:

    ^.*\(d{4})-\d{2}-\d{2}.*$
    

提交回复
热议问题