我想从这些文字中提取出生日期。有四个条件:
keywords to match
Date of Birth
date of birth:
D.O.B:
DOB:
像这样的字符串:
text = "my name is adam my DOB: 30-11-1988 and i play football since 20-2011"
text = "my name is D.O.B: 20/MAY/1987 and i play football since 20-2011"
text = "my Date of Birth 12-7-1970 and i start study since 20-2011"
text = "my date of birth: 20/9/1970 "
你可以这样做:
您的第2组将包含任何格式的捕获日期
现场演示here
解释
(Date of Birth|date of birth|D.O.B|DOB)
:寻找dob短语的任何替代词李>:\s
:查找后跟空格字符的冒号李>(\S*)
:查找任意数量的连续非空格字符,这是您想要的日期李>希望对你有用
相关问题 更多 >
编程相关推荐