编程废柴- 2022-06-09 08:52 采纳率: 100%
浏览 38
已结题

Python正则表达式匹配开头大写或小写的单词怎么敲代码啊

Python正则表达式匹配开头大写或小写的单词怎么敲代码啊
感谢

  • 写回答

2条回答 默认 最新

  • foreverliuyin 2022-06-09 09:30
    关注
    import re
     
    line = """Being able to match varying sets of characters is the first thing regular expressions can do that isn’t
    already possible with the methods available on strings. However, if that was the only additional capability of regexes,
    they wouldn’t be much of an advance. Another capability is that you can specify that portions of the RE must be repeated
    a certain number of times. """
    
    p=re.compile('[a-zA-Z]+',re.M)
    m = p.findall(line)
     
    if m:
       print ("结果 : ", m)
    else:
       print ("无匹配结果")
    

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 6月17日
  • 已采纳回答 6月9日
  • 创建了问题 6月9日

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度