0

I am trying to detect email from clipboard using regex.

Sample Input:

sifii203@gmail.com
sifat@yahoo.com
1232@hotmail.com

Code:

import pyperclip,re

text = pyperclip.paste()
if text:
    agentNamesRegex = re.compile(r'\w+\d*@\w+\.\w+')
    matches = []
    print(agentNamesRegex.findall(text))

Output:(that I am getting)

['sifii203@gmail.com', 'sifat@yahoo.com', '1232@hotmail.com']

Why is 1232@hotmail.com part of the output when I have predefined \w+ which means at least one character will be the suffix?

What am I doing wrong?

Md Sifatul Islam
  • 748
  • 7
  • 27

0 Answers0