str_2只能匹配出来第一个

str_2只能匹配出来第一个

问题描述:

只能匹配出来第一个,后续的无法匹配出来

相关截图:

https://img1.sycdn.imooc.com//climg/64d3569f0999e84405990132.jpg

相关代码:

import re

str_1 = 'I don\'t want to be your entire world, just the best thing in it, I want to say "$%^&*@#~!".'
str_2 = "12i3 love 34you3 not 56because of 7who3 119  df44"

result_1 = re.findall('\".*\"', str_1)
print(result_1)

result_2 = re.findall('^\s*\d\S*\d\s*', str_2)
print(result_2)


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学,你好!是^的问题,^只会匹配以^后开头的内容,不会匹配其它内容,去掉即可

https://img1.sycdn.imooc.com//climg/64d362ed0971a14c05860242.jpg

祝学习愉快!

  • 曲别针010 提问者 #1

    明白了,谢谢老师

    2023-08-10 10:06:32
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师