Regular Expression email address Python [duplicate]
This question already has an answer here:
Regex to extract top level domain from email address
4 answers
I want to extract top level domains from email addresses with Python.
I want to use a regular expression to get everything after the FIRST dot after the @ symbol
E.g.
tony.manero@testing.com
ted.br@top.domain.us
Expected result
.com
.domain.us
How can I use regex to achieve this result?
python regex
marked as duplicate by Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Regex to extract top level domain from email address
4 answers
I want to extract top level domains from email addresses with Python.
I want to use a regular expression to get everything after the FIRST dot after the @ symbol
E.g.
tony.manero@testing.com
ted.br@top.domain.us
Expected result
.com
.domain.us
How can I use regex to achieve this result?
python regex
marked as duplicate by Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Regex to extract top level domain from email address
4 answers
I want to extract top level domains from email addresses with Python.
I want to use a regular expression to get everything after the FIRST dot after the @ symbol
E.g.
tony.manero@testing.com
ted.br@top.domain.us
Expected result
.com
.domain.us
How can I use regex to achieve this result?
python regex
This question already has an answer here:
Regex to extract top level domain from email address
4 answers
I want to extract top level domains from email addresses with Python.
I want to use a regular expression to get everything after the FIRST dot after the @ symbol
E.g.
tony.manero@testing.com
ted.br@top.domain.us
Expected result
.com
.domain.us
How can I use regex to achieve this result?
This question already has an answer here:
Regex to extract top level domain from email address
4 answers
python regex
python regex
asked Nov 19 '18 at 15:34
AlexAlex
3671418
3671418
marked as duplicate by Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Wiktor Stribiżew
StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 '18 at 16:58
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can try this regex and capture group 1 content,
@.*?.(.*)
Demo
Explanation:
- @.*?. --> Matches @ character followed by any characters in non-greedy way followed by a literal dot
- (.*) --> Capture whatever remains after that which is top level domain name
Here is a sample python code,
import re
s = ['tony.manero@testing.com','ted.br@top.domain.us']
for a in s:
print (a,' --> ',re.findall('@.*?.(.*)',a))
This prints following output,
tony.manero@testing.com --> ['com']
ted.br@top.domain.us --> ['domain.us']
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can try this regex and capture group 1 content,
@.*?.(.*)
Demo
Explanation:
- @.*?. --> Matches @ character followed by any characters in non-greedy way followed by a literal dot
- (.*) --> Capture whatever remains after that which is top level domain name
Here is a sample python code,
import re
s = ['tony.manero@testing.com','ted.br@top.domain.us']
for a in s:
print (a,' --> ',re.findall('@.*?.(.*)',a))
This prints following output,
tony.manero@testing.com --> ['com']
ted.br@top.domain.us --> ['domain.us']
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
add a comment |
You can try this regex and capture group 1 content,
@.*?.(.*)
Demo
Explanation:
- @.*?. --> Matches @ character followed by any characters in non-greedy way followed by a literal dot
- (.*) --> Capture whatever remains after that which is top level domain name
Here is a sample python code,
import re
s = ['tony.manero@testing.com','ted.br@top.domain.us']
for a in s:
print (a,' --> ',re.findall('@.*?.(.*)',a))
This prints following output,
tony.manero@testing.com --> ['com']
ted.br@top.domain.us --> ['domain.us']
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
add a comment |
You can try this regex and capture group 1 content,
@.*?.(.*)
Demo
Explanation:
- @.*?. --> Matches @ character followed by any characters in non-greedy way followed by a literal dot
- (.*) --> Capture whatever remains after that which is top level domain name
Here is a sample python code,
import re
s = ['tony.manero@testing.com','ted.br@top.domain.us']
for a in s:
print (a,' --> ',re.findall('@.*?.(.*)',a))
This prints following output,
tony.manero@testing.com --> ['com']
ted.br@top.domain.us --> ['domain.us']
You can try this regex and capture group 1 content,
@.*?.(.*)
Demo
Explanation:
- @.*?. --> Matches @ character followed by any characters in non-greedy way followed by a literal dot
- (.*) --> Capture whatever remains after that which is top level domain name
Here is a sample python code,
import re
s = ['tony.manero@testing.com','ted.br@top.domain.us']
for a in s:
print (a,' --> ',re.findall('@.*?.(.*)',a))
This prints following output,
tony.manero@testing.com --> ['com']
ted.br@top.domain.us --> ['domain.us']
edited Nov 19 '18 at 15:42
answered Nov 19 '18 at 15:35
Pushpesh Kumar RajwanshiPushpesh Kumar Rajwanshi
6,2032827
6,2032827
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
add a comment |
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Thank you! what if I'd like to capture everything after the @ symbol, without stopping at the first dot?
– Alex
Nov 19 '18 at 15:47
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
Little change in regex needed and it becomes @(.*)
– Pushpesh Kumar Rajwanshi
Nov 19 '18 at 15:48
add a comment |