learn-regex-zh icon indicating copy to clipboard operation
learn-regex-zh copied to clipboard

匹配多个同样的模式串

Open Gavingx opened this issue 5 years ago • 1 comments

假如有这么个字符串:2020年8月15日我来到了北京,想起了2013年的事情,现在已经是9时43分了。用正则怎么抽出["2020年8月15日", "2013年”, "9时43分”]? 即:我想抽出某个字符串中的日期和时间,但是不期望得到["2020年", "8月", "15日", "2013年", "9时", "43分"]?

Gavingx avatar Jun 19 '20 11:06 Gavingx

(\d{1,4}[月日年时分秒]){1,3}

2531 avatar Mar 28 '21 12:03 2531