m0_58184981 2022-05-30 20:00 采纳率: 45.5%
浏览 28
已结题

用正则提取一段文字,该怎么写,文本如下

用正则提取一段文字,该怎么写,文本如下:
Text:
Hello,
<br><br>
Click the link below to finish your login to bo.qa.atomictitan.dev:
<br>
https://enlabs-dev.cloudflareaccess.com/?nonce=P0FoMt8z0zVTD6zE6LKRVknk6okRMTY1MzkwNTQ2MQ&code=433507

<br><br>
You can also copy and paste the code below into the Cloudflare Access login screen:
<br><br>
433507
<br><br>
This code will expire after 10 minutes or if you request a new code.
<br><br>
Thanks,
<br><br>
The Cloudflare Team

想要提取433507这个文本

  • 写回答

2条回答 默认 最新

  • A Python 萌新花花 2022-05-30 20:16
    关注
    
    import re
    a = """<br><br>
    You can also copy and paste the code below into the Cloudflare Access login screen:
    <br><br>
    433507"""
    s = re.findall(r"[0-9]+",a)
    print(s[0])
    
    

    仅针对这段文本,如果你想要正则一个html文本的话,需要前后文,不然容易锁定错

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

报告相同问题?

问题事件

  • 系统已结题 6月8日
  • 已采纳回答 5月31日
  • 修改了问题 5月31日
  • 修改了问题 5月30日
  • 展开全部

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作