python 捕獲分組(xxx)與非捕獲分組(?:xxx)


 

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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM