简体   繁体   中英

How to catch a string based on a subsection of it

I have multiple strings in a list.

Each list is a link in a string format.

I have some strings whose style is the following:

mailto:newsletter.dcda@dcda.com

Some of these strings change in the @ part. They have different addresses.

I want to find a regular expression that can capture the whole text based on the mailto:

part.

Maybe this expression will work

import re

t='mailto:newsletter.dcda@dcda.com'
re.findall('mailto:(?:\w+\.?)+@(?:\w+\.?)+',t)

['mailto:newsletter.dcda@dcda.com']

RegExp test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM