:type emails: List[str] :rtype: int
(self, emails)
| 39 | |
| 40 | class Solution(object): |
| 41 | def numUniqueEmails(self, emails): |
| 42 | """ |
| 43 | :type emails: List[str] |
| 44 | :rtype: int |
| 45 | """ |
| 46 | |
| 47 | result = 0 |
| 48 | # local = {} |
| 49 | _emails = set() |
| 50 | ignore = re.compile(r'\+(.*)') |
| 51 | for i in emails: |
| 52 | x = i.split('@') |
| 53 | if len(x) > 2: |
| 54 | continue |
| 55 | |
| 56 | if len(x) == 1: |
| 57 | continue |
| 58 | |
| 59 | local = x[0] |
| 60 | domain = x[1] |
| 61 | local = local.replace('.', '') |
| 62 | |
| 63 | |
| 64 | local = re.sub(ignore, '', local) |
| 65 | |
| 66 | _emails.add(local + '@' + domain) |
| 67 | |
| 68 | return len(_emails) |
| 69 |