在这里,我只想从email id中提取alpitananad。你知道吗
import re
def extracter(text):
reg1 = re.compile(r'(\d{3}|\(\d{3}\))?(\s|-|\.)?(\d{3})(\s|-|\.)(\d{4})')
se1 = reg1.findall(text)
print(se1)
for i in range(len(se1)):
print(''.join(se1[i]))
reg2 = re.compile(r'([a-zA-Z0-9]+@+[a-zA-Z0-9]+\.[a-zA-Z]{2,4})')
reg3 = re.compile(r'[a-zA-Z0-9]+@')
se3 = reg3.findall(text)
se2 = reg2.findall(text)
print(se2)
print(se3)
text1 = "123-434-2432 of may name is jsdiofhsdio fh diofh dui fjf ui834y8 fwe8fweuihwe 8f e87f y87 456-243-3434 ajsfhj alpitanand20@gamil.com"
extracter(text1)
我得到的结果是
[('123', '-', '434', '-', '2432'), ('456', '-', '243', '-', '3434')]
123-434-2432
456-243-3434
['alpitanand20@gamil.com']
['alpitanand20@']
我只需要一个输出来检查前一个字符串@。我应该在reg3中做什么更改。谢谢您。。!!!你知道吗
以下应起作用:
输出:
相关问题 更多 >
编程相关推荐