首页 > 编程语言 > 详细

python 捕获分组(xxx)与非捕获分组(?:xxx)

时间:2020-02-14 13:58:39      阅读:77      评论:0      收藏:0      [点我收藏+]

 

findall 的捕获分组与非捕获分组

# -*- coding:utf-8 -*
import re
str1 = ‘fdg@163.com  abc@qq.com‘
reg_str1=r‘([0-9a-zA-Z_]+)+@‘# 打印结果 [‘fdg‘, ‘abc‘]
#reg_str1=r‘(?:[0-9a-zA-Z_]+)+@‘# 打印结果 [‘fdg@‘, ‘abc@‘]
mod = re.compile(reg_str1)
items = mod.findall(str1)
print(items)

 

python 捕获分组(xxx)与非捕获分组(?:xxx)

原文:https://www.cnblogs.com/taoyuanming/p/12306950.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!