学习笔记(17):Python 面试100讲(基于Python3.x)-用正则表达式判断字符串中是否包含日期...

立即学习:https://edu.csdn.net/course/play/26755/340145?utm_source=blogtoedu

match 匹配:

s='today is 2010-07-08'

m=re.match('.*\d{4}-\d{2}-\d{2}.*' ,s)#其中.*代表多个字符,\d(4)代表4个字符。

if m is not None :

    print(m.group())

发布了26 篇原创文章 · 获赞 2 · 访问量 279

猜你喜欢

转载自blog.csdn.net/qq_35504363/article/details/104296015
今日推荐