Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีดึง email ID จากข้อความด้วย Python Regular Expression

ใช้ Python regex ดึง email id จากสตริง/ข้อความที่กำหนด

ตัวอย่าง

import re
s = 'manogna@tutorialspoint.com56'
result = re.findall('[a-zA-Z0-9]\S*@\S*[a-zA-Z]', s)
print(result)

ผลลัพธ์

['manogna@tutorialspoint.com']