यहां हम URL-पाठ फ़ाइल से ईमेल-आईडी निकालने के लिए रेगुलर एक्सप्रेशन पैकेज का उपयोग कर रहे हैं। URL- टेक्स्ट फ़ाइल को देखते हुए। रेगुलर एक्सप्रेशन पैकेज का उपयोग करके हम ईमेल-आईडी के पैटर्न को परिभाषित करते हैं, फिर इस पद्धति का उपयोग करके इस पद्धति का उपयोग करके टेक्स्ट की जांच करते हैं जो इस पैटर्न से मेल खाएगा।
Input text= Please contact us at contact@tutorialspoint.com for further information."+\ " You can also give feedback at feedback@tutorialspoint.com" Output ['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’]