正则表达式断言

https://www.runoob.com/w3cnote/reg-lookahead-lookbehind.html

取前面不是数字,后面不是数字,中间是四位数的
query = "12356/2022安徽光伏政策2222"
re.findall('(?<!\d)\d{4}(?!\d)', query)

posted @ 2022-03-02 17:16  douzujun  阅读(63)  评论(0编辑  收藏  举报