Regular Expression email address Python [duplicate]












-2
















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?










share|improve this question













marked as duplicate by Wiktor Stribiżew python
Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

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.




















    -2
















    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?










    share|improve this question













    marked as duplicate by Wiktor Stribiżew python
    Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

    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.


















      -2












      -2








      -2









      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?










      share|improve this question















      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 15:34









      AlexAlex

      3671418




      3671418




      marked as duplicate by Wiktor Stribiżew python
      Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

      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 python
      Users with the  python badge can single-handedly close python questions as duplicates and reopen them as needed.

      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.


























          1 Answer
          1






          active

          oldest

          votes


















          2














          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']





          share|improve this answer


























          • 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


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          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']





          share|improve this answer


























          • 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
















          2














          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']





          share|improve this answer


























          • 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














          2












          2








          2







          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']





          share|improve this answer















          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']






          share|improve this answer














          share|improve this answer



          share|improve this answer








          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



















          • 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



          Popular posts from this blog

          Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

          ComboBox Display Member on multiple fields

          Is it possible to collect Nectar points via Trainline?