यहाँ हम URL-टेक्स्ट फ़ाइल से ईमेल-आईडी निकालने के लिए नियमित अभिव्यक्ति पैकेज का उपयोग कर रहे हैं। दिया गया URL-टेक्स्ट फ़ाइल। नियमित अभिव्यक्ति पैकेज का उपयोग करके हम ईमेल-आईडी का पैटर्न परिभाषित करते हैं फिर findall() फ़ंक्शन का उपयोग करते हैं, इस मेथड का उपयोग उस टेक्स्ट की जांच करने के लिए जो इस पैटर्न से मेल खाएगा।
इनपुट टेक्स्ट= Please contact us at contact@tutorialspoint.com for further information."+\ " You can also give feedback at feedback@tutorialspoint.com" आउटपुट ['contact@tutorialspoint.com ', 'feedback@tutorialspoint.com']
उदाहरण कोड
import re my_text = "Please contact us at contact@tutorialspoint.com for further information."+\ " You can also give feedback at feedback@tutorialspoint.com" my_emails = re.findall(r"[a-z0-9\.\-+_]+@[a-z0-9\.\-+_]+\.[a-z]+", my_text) print(my_emails)
आउटपुट
['contact@tutorialspoint.com', 'feedback@tutorialspoint.com']