您的位置:首页技术文章
文章详情页

Python正则表达式提取字符串部分内容

浏览:94日期:2022-06-28 18:11:07

问题描述

样本:user<user@test.com>如何提取其中的 user@test.com 部分?

问一下,用Python 正则如何最优实现?

问题解答

回答1:

import restr = ’user<user@test.com>’print re.search(’<(.+)>’, str).group(1)回答2:

# coding: utf8import restring = ’user<user@test.com>’print re.findall(r’<([^>]+)’, string)

标签: Python 编程
相关文章: